How to plot a bar graph for individual values?

I need a bar graph for these values with colorjet. The points (1,0), (1,0.1), (1,0.2), (1,0.3), (1,0.4) and (1,0.5) with values respectively 0.725, 0.654, 0.543, 0.812, 0.698 and 0.456 And The points (2,0), (2,0.1), (2,0.2), (2,0.3), (2,0.4) and (2,0.5) with values respectively 0.628, 0.652, 0.783, 0.682, 0.758 and 0.765.

 採用された回答

Chunru
Chunru 2023 年 9 月 21 日

0 投票

x = 1:2;
y = 0:0.1:0.5;
z = [0.725, 0.654, 0.543, 0.812, 0.698, 0.456;
0.628, 0.652, 0.783, 0.682, 0.758, 0.765];
b = bar3(y, z');
for i=1:length(b)
b(i).CData = b(i).ZData;
b(i).FaceColor = "interp";
end
colormap(jet)

8 件のコメント

GULZAR
GULZAR 2023 年 9 月 21 日
Thank you so much...But i need 2D graph like this...Can you let me know
Chunru
Chunru 2023 年 9 月 21 日
use "view(2)"
x = 1:2;
y = 0:0.1:0.5;
z = [0.725, 0.654, 0.543, 0.812, 0.698, 0.456;
0.628, 0.652, 0.783, 0.682, 0.758, 0.765];
b = bar3(y, z');
for i=1:length(b)
b(i).CData = b(i).ZData;
b(i).FaceColor = "interp";
end
colormap(jet)
view(2); colorbar
GULZAR
GULZAR 2023 年 9 月 21 日
Thank you...
GULZAR
GULZAR 2023 年 9 月 21 日
Here we want change x value. But It is not working. Why we are not using the x values in this program.
Chunru
Chunru 2023 年 9 月 21 日
That is the limitation of bar3 function. (You can try xtick and xticklabel).
If you want the flexibility, refer to the following:
GULZAR
GULZAR 2023 年 9 月 21 日
okay, thank you
GULZAR
GULZAR 2023 年 9 月 26 日
編集済み: GULZAR 2023 年 9 月 26 日
In view(2); colorbar;
The layout is separated. I need joined layout. Can you let me know....
Chunru
Chunru 2023 年 9 月 26 日
Use "width" for bar3
x = 1:2;
y = 0:0.1:0.5;
z = [0.725, 0.654, 0.543, 0.812, 0.698, 0.456;
0.628, 0.652, 0.783, 0.682, 0.758, 0.765];
width = 1;
b = bar3(y, z', width);
for i=1:length(b)
b(i).CData = b(i).ZData;
b(i).FaceColor = "interp";
end
colormap(jet)
view(2); colorbar

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 9 月 21 日

コメント済み:

2023 年 9 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by