Force axes to always be on top of another axes

11 views (last 30 days)
I'm developing a data review tool that allows the user to create many plots in a figure. When an axes is clicked, the color changes to show the user which axes is the current axes for additional graphing tools (Add more data, scale the data, etc.).
I'd like to give the option to plot differently scaled data on the same axes but with different Y axes scaling. I tried to use plotyy but it doesn't allow me to continue to manipulate the data so I am trying to develop my own version.
Here's my problem: I create the new axes with Color = 'none' and HitTest = 'off'. When clicking on those axes, the old axes moves to the 'front' and covers up the new axes. How do I force the new axes to always be on top so the color management and callbacks can still be managed via the original axes.
Thanks for any insight! Scott

Accepted Answer

per isakson
per isakson on 18 Feb 2014
Edited: per isakson on 18 Feb 2014
Without understanding your requirements in detail:
  • This is too much to do with Matlab
  • The new version of graphics, HG2, might appear in a couple of weeks in R2014a.
  • See Undocumented Matlab
  • I recall vaguely that the order of the axes-handles in the property, Children, of the parent affects the rendering (z-order).
  • "old axes moves to the 'front' and covers up the new axes" That's intended behavior; doc says: If HitTest is off, clicking the axes selects the object below it.
  • "show the user which axes is the current axes" is that among axes, which are on top of each other? That would be more like "layers".
  1 Comment
Scott
Scott on 20 Feb 2014
Thanks so much! I changed which axes had HitTest on and just checked if there was a sibling axes through appdata of the upper axes. I then set the siblingAxes' color.
Your answer also gave me a way to fix another problem I hadn't mentioned - I made the axes moveable by dragging and dropping them. The axes that is being moved would pass above or below the other axes in the figure. If there were two axes at a single location, the axes being moved could appear between them. By setting the order of the axes handles in the Children property of the figure, I can control which axes is most forward and which is most rearward. Nice touch.

Sign in to comment.

More Answers (0)

Categories

Find more on Two y-axis 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!