Plotting a Stacked Bar graph using different X values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I have two different data sets, say
x1 = [1 2 3]
x2 = [2 3 4]
y1 = [5,6,7]
y2 = [10,12,21]
I want to plot the two data sets as a stacked bar graph. Problem is, the "bar" function does not allow you to use different x values...I think...unless I am doing something wrong. Anyone know a way around this?
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 10 Sep 2013
Modifié(e) : Azzi Abdelmalek
le 10 Sep 2013
x1 = [1 2 3]
x2 = [2 3 4]
y1 = [5,6,7]
y2 = [10,12,21]
x=unique([x1 x2])
yy1=nan(1,numel(x));
yy2=yy1;
yy1(ismember(x,x1))=y1
yy2(ismember(x,x2))=y2
bar(x,[yy1;yy2]')
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Discrete Data Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!