Create floating bars, grouping each set of bars by a single month

39 ビュー (過去 30 日間)
Ali Afruzi
Ali Afruzi 2021 年 3 月 5 日
コメント済み: Star Strider 2021 年 3 月 6 日
Hi there,
I need to create floating bars like the picture below. I attached the data that is required to create the graph.
Each bar has minimum, mean, and maximum values and the bars are grouped for each month to show the results of 7 or more models.
I should also mention that this graph is created in NCL Graphics: Bar Charts using bar_13
Thanks!

採用された回答

Star Strider
Star Strider 2021 年 3 月 5 日
Esperiment with this:
T1 = readtable('dummy_model_data.txt', 'HeaderLines',1);
T1.Properties.VariableNames = {'Model','Min','Max','Mean'};
BlueBars = [reshape([reshape(T1.Min, 7, []); nan(1,3)], 1,[]); reshape([reshape(T1.Mean, 7, []); nan(1,3)], 1,[])];
RedBars = [reshape([reshape(T1.Max, 7, []); nan(1,3)], 1,[]); reshape([reshape(T1.Mean, 7, []); nan(1,3)],1,[])];
Models = reshape([reshape(T1.Model, 7, []); cell(1,3)], [], 1);
figure
plot([1;1]*(1:size(BlueBars,2)), BlueBars, 'b', 'LineWidth',15)
hold on
plot([1;1]*(1:size(RedBars,2)), RedBars, 'r', 'LineWidth',15)
hold off
set(gca, 'XTick',(1:size(BlueBars,2)), 'XTickLabel',Models, 'XTickLabelRotation',90)
pos = get(gcf,'Position');
text(4:8:24, ones(1,3)*-80, compose('%s 2007', ['JAN';'MAR';'MAY']))
set(gcf, 'Position', pos+[0 -250 500 250])
producing:
.
  2 件のコメント
Ali Afruzi
Ali Afruzi 2021 年 3 月 6 日
Thank you!
Star Strider
Star Strider 2021 年 3 月 6 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by