Multiple bar plot of different datasets in the same figure

3 ビュー (過去 30 日間)
Emerson Lyra
Emerson Lyra 2022 年 5 月 17 日
コメント済み: Emerson Lyra 2022 年 5 月 18 日
Hi folks!
I would like to create a bar plot similar to the attached figure.
The reference https://www.mathworks.com/help/matlab/ref/bar.html reports how to plot datasets like the green and blue bars. Ok.
In the same figure, is it possible to insert two additional single bars like the yellow and red in the image?
If possible, could someone more experienced suggest a way to do this by code? How could I put the x-axis tick labels in this case?
Ps: I'm using Matlab R2018a
Best,

採用された回答

Chunru
Chunru 2022 年 5 月 18 日
x = rand(6,2);
b = bar(x);
% control the color of individual bar
% 1st group first bar
b(1).FaceColor = 'flat';
b(1).CData(1,:) = [.8 0 .8];
% 2nd group first bar
b(2).FaceColor = 'flat';
b(2).CData(1,:) = [.2 .8 0];
  1 件のコメント
Emerson Lyra
Emerson Lyra 2022 年 5 月 18 日
@Chunru It wasn't quite what I was looking for but it's a solution that works! It's just better if I plot all the single bars and color them according to grouping. Thanks! best!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by