Bar Graph Stacked with Negative and Positive values
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brishen
le 7 Oct 2011
Modifié(e) : Koorosh Aslansefat
le 17 Juil 2020
Hi.
I'm trying to get a plot to act like the graph function in excel that stacks values together. It does this by putting all positive values on the positive part of the axis, and the negative values on the negative side.
Unfortunatly when I use bar(X,'stack') with matlab it doesn't do this.
Is there any way to get this same functionality? Thanks.
0 commentaires
Réponse acceptée
Plus de réponses (2)
Walter Roberson
le 7 Oct 2011
It isn't clear to me that what you describe would be appropriate? 'stacked' means to show the cumulative sum with internal divisions. If some members of the bar are positive and others are negative, then if you have a break at the axis then you misrepresent the cumulative sum.
2 commentaires
Walter Roberson
le 7 Oct 2011
Something like this, perhaps:
t1 = X;
t2 = X;
t1(t1<0) = nan;
t2(t2>0) = nan;
Xsplit = reshape([t2.';t1.'],size(t,2),[]).';
bar(Xsplit,'stacked')
Koorosh Aslansefat
le 17 Juil 2020
Modifié(e) : Koorosh Aslansefat
le 17 Juil 2020
I would suggest to try this:
bar(X,'BaseValue',0)

0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D 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!