Plotting 2 arrays as bar charts with adjacent bars

7 ビュー (過去 30 日間)
Murtaza Mohammadi
Murtaza Mohammadi 2022 年 11 月 15 日
コメント済み: Murtaza Mohammadi 2022 年 11 月 18 日
I have two arrays A and B, each of 8 elements. I want to plot them as bar charts with each corresponding element plotted as adjacent bars. The bar tool overlaps and makes it difficult to handle the properties. The target is something like this (see image).
Thank you

採用された回答

VBBV
VBBV 2022 年 11 月 15 日
A = rand(1,8);
B = rand(1,8);
bar([1 2 3 4 5 6 7 8],[A;B]); % use concatenation

その他の回答 (1 件)

Murtaza Mohammadi
Murtaza Mohammadi 2022 年 11 月 15 日
I managed to achieve it by using the following command.
bar([1 2 3 4 5 6 7 8],vertcat(A, B));
Is there any solution more elegant?
Thanks

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by