How to plot bar graph with colorscale?

I need a bar graph like the picture given below 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.

2 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 26 日
What do these values mean? What is their significane and relation with each other?
GULZAR
GULZAR 2023 年 9 月 26 日
Transmittance values with thickness variation from 0 to 0.5 with different two structures of optics

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

 採用された回答

檮杌
檮杌 2023 年 9 月 27 日
編集済み: 檮杌 2023 年 9 月 27 日

0 投票

Would this work for you?
thickness = ones(2,6)*0.1;
vals = [0.725, 0.654, 0.543, 0.812, 0.698, 0.456;
0.628, 0.652, 0.783, 0.682, 0.758, 0.765];
figure;
hb = barh(thickness ,'BarLayout','stacked','FaceColor','flat');
cmap = jet(256);
for i = 1:6
hb(i).CData = cmap(round(vals(:, i)*256),:);
end
cbar = colorbar;
ylabel(cbar, "Transmittance")
colormap(cmap);
xlabel("Thickness");
ylabel("Structure");

4 件のコメント

GULZAR
GULZAR 2023 年 9 月 27 日
Thank you so much
GULZAR
GULZAR 2023 年 9 月 27 日
One more favor to me. How to convert X and Y axis. I need Structure in horizontal and Thickness in Vertical axis.
檮杌
檮杌 2023 年 9 月 27 日
You can use "bar" instead of "barh" to swap X and Y axis.
Also, do not forget to change xlabel and ylabel too.
GULZAR
GULZAR 2023 年 9 月 27 日
Thank you...its working

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 9 月 26 日

コメント済み:

2023 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by