bar location

  • Follow


Hi all,

I have a grouped bar group, for example, 

data = rand(3,4).*10;
bar(data)

I want to annotate the first bar in each group, then the second, and so on. I am wondering if there is a way that I can get the x location of each bar.

Thank you in advance, 
Wendy 
0
Reply Wendy 7/4/2010 9:14:07 PM

"Wendy " <wlq121@gmail.com> wrote in message <i0qtiu$dvk$1@fred.mathworks.com>...
> Hi all,
> 
> I have a grouped bar group, for example, 
> 
> data = rand(3,4).*10;
> bar(data)
> 
> I want to annotate the first bar in each group, then the second, and so on. I am wondering if there is a way that I can get the x location of each bar.
> 
> Thank you in advance, 
> Wendy 

one of the solutions

     m=rand(3,4).*10;
     bh=bar(m);
     bc=get(bh,'children');
     bp=get([bc{:}],'xdata');
     bp=cat(2,bp{:});     % <- X coordinates of each bar-patch...
     bd=diff(bp([1,4],1));     % <- length of each bar-patch

us
0
Reply us 7/4/2010 9:33:05 PM


1 Replies
201 Views

(page loaded in 0.039 seconds)

Similiar Articles:













7/25/2012 1:06:20 PM


Reply: