Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Stack order of patches in barplot
Replies: 2   Last Post: Feb 21, 2013 2:36 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
matt dash

Posts: 628
Registered: 4/18/08
Re: Stack order of patches in barplot
Posted: Feb 10, 2013 12:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

joe778899@gmail.com wrote in message <8ad19955-4349-4ed0-957a-91218550e3b9@googlegroups.com>...
> Hi NG,
>
> I have an axis in which I plot two data sets as bar plots. I have a loop that loads one set, plots it and then loads the next and plots it. The X-values are common to both sets. All good, but in some cases a value of the second set is higher than the first, causing it to cover the first bar that was plotted at that x-position. Is there a way to traverse through the graphic objects and then "move up" a shorter bar so that is in front? As far as I can see, the individual patches (bars) do not have handles, so how to get to them?
>
> Thanks very much in advance!
>
> JS
>
> PS I know that I could of course test both values for each x-value and then simply plot the tallest first, but that is not a very elegant solution IMO..


You could just use the bars' zdata property... set the zdata equal to the negative of the bar height (which should be the max of its ydata property). Then taller bars will be further away --> behind. (You may need to repmat this value to make zdata the same dimensions as xdata/ydata.)



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.