remove the space between the bars in a bar chart?

38 ビュー (過去 30 日間)
John
John 2012 年 11 月 13 日
コメント済み: Zoran Milenkovic 2021 年 7 月 25 日
Hello,
Is it possible to remove the space between the bars in a bar chart? Where is the option?
Thanks

回答 (2 件)

Image Analyst
Image Analyst 2012 年 11 月 14 日
Try this:
bar(xValues, yValues, 'BarWidth', 1);
You can set the bar width to any fraction between 0 and 1 that you want.
  3 件のコメント
Image Analyst
Image Analyst 2021 年 3 月 28 日
@Torkan, well not "just". Did you actually try it? By changing the width fraction, you are changing the fraction of the distance between one bar and the next that a bar takes up. This changes both the bar width and the spacing between the bars. All you have to do it try it and see:
xValues = 1 : 4;
yValues = rand(1, length(xValues))
subplot(2, 1, 1);
bar(xValues, yValues, 'BarWidth', 0.7);
subplot(2, 1, 2);
bar(xValues, yValues, 'BarWidth', 1);
Do you see now how the relative proportion of bar and space can be adjusted? And @John wanted to "remove the space between the bars", and using 1 will do exactly that. Though I'm not sure why he has not accepted the answer yet. Perhaps he'll come back and say why this answer was not accepted, but since it's been 9 years, I doubt it.
Zoran Milenkovic
Zoran Milenkovic 2021 年 7 月 25 日
This worked for me. Thanks!

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


Honglei Chen
Honglei Chen 2012 年 11 月 13 日
編集済み: Honglei Chen 2012 年 11 月 14 日
Are you looking for something like below?
bar(1:10,1:10,1)
The last argument, 1, stands for bar width.

カテゴリ

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