Grouped Bar Series Xdata in 2014b
2 views (last 30 days)
Show older comments
In Matlab versions prior to 2014b we could get the x-position of individual bars in a bar series like this:
hBar = bar(data);
x = get(get(hBar,'children'),'xdata');
With R2014b this does not work anymore. This breaks a lot of my existing code, thanks Mathworks! Is there a way to get the x-position of individual bars in a bar series in version 2014b?
0 Comments
Accepted Answer
Kelly Kearney
on 15 Jan 2015
You can get the position of the centers of each bar through the XOffset property:
hBar = bar(rand(10,5));
xb = bsxfun(@plus, hBar(1).XData, [hBar.XOffset]');
5 Comments
More Answers (1)
Star Strider
on 15 Jan 2015
Edited: Star Strider
on 15 Jan 2015
That’s no longer possible. I submitted a Support Request complaining about the useful features in R2014a and earlier that were lost in HG2. Complain directly, and maybe MATLAB graphics will be useful again some day. I doubt there will be any immediate miracles, though.
Meanwhile, don’t uninstall R2014a ! (I haven’t.) You can have R2014a and R2014b open at the same time if you need to do something in R2014b that isn’t in R2014a, then pass the result to R2014a as a .mat file to do useful graphics.
EDIT —
Tell them to add the information in Kelly’s Answer in the ‘official’ documentation. She must have gotten in from the ‘Undocumented MATLAB’ site.
0 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!