Bar Graph Stacked with Negative and Positive values
20 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(2 个)
Walter Roberson
2011-10-7
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 个评论
Walter Roberson
2011-10-7
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
2020-7-17
编辑:Koorosh Aslansefat
2020-7-17
I would suggest to try this:
bar(X,'BaseValue',0)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!