How to set bar beginning value?

36 ビュー (過去 30 日間)
Maksym Klitsman
Maksym Klitsman 2017 年 8 月 11 日
コメント済み: Paris Pasqualin 2022 年 4 月 26 日
Hello Community,
i want to ask a question about bar graph. By default the beginning of each bar is zero-value. I need to show such group of bars (that means no 'stacked' style), while bar beginning shows minimum value and bar ending shows maximum value. Minimum and maximum is not always negative and positive respectively. That means the bar in bar group could just "hang is the air".
How can i do this? I could do this through 'stacked' style, making first bar invicible. But i need exact grouped style.
Please help and thank you!
Maksym Klitsman
  2 件のコメント
José-Luis
José-Luis 2017 年 8 月 11 日
Could you post an example of the look you are trying to achieve?
Maksym Klitsman
Maksym Klitsman 2017 年 8 月 11 日
of course, sorry if I not clearly told what i want

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

採用された回答

José-Luis
José-Luis 2017 年 8 月 11 日
aH = axes;
minimum = rand(10,3);
maximum = rand(10,3) + minimum;
bH = bar(maximum);
hold on;
bH1 = bar(minimum);
for ii = bH1
ii.FaceColor = [1 1 1];
ii.LineStyle = 'None';
ii.EdgeColor = [1 1 1];
end
for ii = bH
ii.LineStyle = 'None';
ii.EdgeColor = [1 1 1];
end
axes('Position',aH.Position,'XTick',[],'YTick',[],'Color','None');
  2 件のコメント
Maksym Klitsman
Maksym Klitsman 2017 年 8 月 11 日
thanks, that's exactly what i wanted to represent!
José-Luis
José-Luis 2017 年 8 月 11 日
My pleasure.

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

その他の回答 (1 件)

Akira Agata
Akira Agata 2017 年 8 月 11 日
If my understanding is correct, what you want to do would be like the following. Is it answering your question??
% Example of min. and max. value of each bar
minimum = [1;-1;3];
maximum = [5;3;7];
h = bar([minimum, maximum-minimum],'stacked','BaseValue',min(minimum));
h(1).Visible = 'off';
set(gca,'YLim',[min(minimum),max(maximum)+1]);
  5 件のコメント
Thomas Wiesen
Thomas Wiesen 2022 年 1 月 28 日
I have a similar issue. I want a bar chart where the bottom of the bar is at some minimum value and the top of the bar is at some maximum value. Does Akira Agata’s code work when there are negative elements? In the second bar, the bottom of the bar should be at -1 and the top of the bar should be at 3. However, when I used this code, the top of the second bar is at 4.
Paris Pasqualin
Paris Pasqualin 2022 年 4 月 26 日
Amazing, thank you.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by