How to set the bars wider apart?

4 views (last 30 days)
David
David on 3 Feb 2013
Hello,
the following link shows a diagram which I want to alter. http://imageshack.us/photo/my-images/38/resbitfull.jpg/
As you can see I have on top of the bars some values which overlap. So I need to set the bars wider apart, but how can I do that? I searched, but could not find any good solution.
My code for printing the values on top of each bar is the following ....
% Find the x location of each bar
xvals = unique(cell2mat(get(findall(hb,'type','patch'),'xdata')));
xvals = mean(reshape(xvals,2,[]));
% Put the text there
text(xvals,[DataFps1 DataFps2 DataFps3 DataFps4 DataFps5], ...
{[DataFpsLabels1 DataFpsLabels2 DataFpsLabels3 DataFpsLabels4 DataFpsLabels5]},...
'Vert','bot','horiz','cen','FontName','Arial','Fontsize',8);
Thank you for helping! David

Answers (2)

Youssef  Khmou
Youssef Khmou on 4 Feb 2013
bar(data,width)
your data is the vector "data" you plot it with specified width , example :
bar(sin(0:0.01:10),0.2)
  1 Comment
David
David on 4 Feb 2013
Hi, if I use width 0.2 I get this:
for 0.9 I get:
So my text overlaps. But this is the reason why I want to set the bars wider apart. Using width seems make bars thinner or thicker, not setting them wider apart.

Sign in to comment.


Matt Tearle
Matt Tearle on 4 Feb 2013
The numbers currently go pretty much right across the width of the figure, so there's not a whole lot of real estate you can gain. You could space out the bars in each group, but only by decreasing the spacing between the groups.
This can be done by hacking around in HG, I think.
But I suspect your best bet is simply to reduce the relative size of the text to the figure, either by reducing the font size or increasing the figure window size.

Community Treasure Hunt

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

Start Hunting!