Rank: 392806 based on 0 downloads (last 30 days) and 0 file submitted



Personal Profile:


Watch this Author's files


Comments and Ratings by Brett View all
Updated File Comments Rating
22 Aug 2013 GUI Layout Toolbox Layout management objects for MATLAB GUIs Author: Ben Tordoff

I have used several axes in different tabs within layouts. I needed the ability to do plotyy type plotting as well. My workaround is to place all axes inside a uipanel. This way the uipanel acts as a container for the axes. This also allows the panel to have multiple overlapping children without the uitab's layout separating them into its layout.

13 Aug 2013 legendflex.m: a more flexible, customizable legend Create a legend with more flexible positioning and labeling capabilities Author: Kelly Kearney

This is what I was looking for, but I had to fix it to work well for axes embedded in complicated layouts involving uipanels, uitabs, etc. I use the excellent GUI Layout Toolbox from here on the file exchange to have lots of resizeable panels for example.

The problem is that this function assumes the legend should be placed relative to the figure. Unfortunately if a nested uipanel is used as a reference, the getpos() function does not correctly return the figure coordinates relative to the anchor. To get the global figure coordinates for a nested object, the GUI's hierarchy must be traversed, and the left and bottom coordinates summed for each parent up to the figure level. Each control's position is relative to it's parent, not to the figure.

Fortunately there's a simpler solution. I made the legend a child of the 'ref' object and fixed anywhere that temporary axes were made to the figure to be to the ref object instead. I also added a check that if this parent object is an axes, to get it's parent since the legend axes can't be a child of another axes. Finally, in the case of a plot in a densely nested GUI, the resize function should be on the parent component, not on the entire figure. This way when I drag the boundaries between uipanels to resize them, the legend and axes resize with them. I'm still experimenting with it, but this seems to solve my problems thus far.

I'll wait on permission to post my code since the author listed a copyright in the source.

Contact us