Smaller values not seen in bar graph
3 次查看(过去 30 天)
显示 更早的评论
Hi, I want to show boundaries of two variables in bar graph. However, when I add second variable to bar graph, smaller value of first value disappear in bar graph (such as y=7, y=8). I didnt find way to make it appears.
X=[5 4 3];
Y=[1 7 8];
bar(X)
hold on
bar(Y)
0 个评论
采纳的回答
Chunru
2021-12-6
编辑:Chunru
2021-12-6
X=[5 4 3];
Y=[1 7 8];
bar([X; Y]')
figure
bar(X)
hold on
bar(Y, 'FaceAlpha', .5); % transparency
figure
XMin = min(X, Y)';
XMax = max(X, Y)';
bar([XMin, XMax-XMin], 'stacked')
% Idea solution: Plot each bar individually
n = numel(X);
figure; hold on
for i=1:n
if X(i)>Y(i)
bar(i, X(i), 'r');
bar(i, Y(i), 'b');
else
bar(i, Y(i), 'b');
bar(i, X(i), 'r');
end
end
4 个评论
另请参阅
类别
在 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!