フィルターのクリア

Smaller values not seen in bar graph

5 ビュー (過去 30 日間)
Gokhan Kayan
Gokhan Kayan 2021 年 12 月 6 日
編集済み: Gokhan Kayan 2021 年 12 月 6 日
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)

採用された回答

Chunru
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 件のコメント
Chunru
Chunru 2021 年 12 月 6 日
See the updated for an ideal solution.
Gokhan Kayan
Gokhan Kayan 2021 年 12 月 6 日
編集済み: Gokhan Kayan 2021 年 12 月 6 日
Oh. The last solution worked perfectly!. Thanks a lot for the help.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2021 年 12 月 6 日
編集済み: KSSV 2021 年 12 月 6 日
You can go ahead like this right?
X=[5 4 3];
Y=[1 7 8];
x = 1:3 ;
bar(x,[X;Y])
Or you can try:
bar([X' Y'],'stacked')
  1 件のコメント
Gokhan Kayan
Gokhan Kayan 2021 年 12 月 6 日
Unfortunately, I dont want them like first way because i will draw line graph too. The graph will be sophisticated. Second graph adds y to x. I dont want summation.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by