I'm trying to install a GUI Layout Toolbox, but nothing happen when i click accept the terms. How can i check if a toolbox has been installed or not? thank you
MATLAB: Gui Layout Toolbox installing
toolbox
Related Solutions
Method 1.
One way of doing it, as explained in the documentation, is to create a uicontainer parent for the axes to enable correct legend/colorbar behavior.
So simply change the axes creation line to the following:
axes1 = axes('Parent', uicontainer('Parent', panel{1}))
Method2.
While this should work perfectly fine for most cases, you may not like the slight (not easily noticeable) shifting of the axes position. I personally needed to come up with another solution for my own GUI due to my obsession on perfect positioning and alignment. This is not as neat as the above method, but does the job and no longer needs to deal with the positioning of a uicontainer object which can get tricky for some cases.
You should first create a VBox or HBox container parent for your axes only. Then create the axes, add the legend, and set the Widths of the HBox or (Heights of the VBox) to [-1 0]. Finally, update your legend handle location value to your liking. I observed that resizing the figure (HBox/VBox axes container) actually resets the location of the legend object for some unknown reason. So I fixed this by adding a SizeChangedFcn callback to the container to fix this.
In short, you can achieve this by replacing your axes creation lines of your code with the following lines:
axesContainer = uix.HBox('Parent',panel{1},'SizeChangedFcn',{@GUIAxesLegendFix;'northeast'});axes1 = axes('Parent', axesContainer);theta = 0:360; plot(axes1,theta, sind(theta), theta, cosd(theta)) LegendHandle = legend('sin','cos');axesContainer.Widths = [-1 0];LegendHandle.Location = 'northeast';
and add this callback function to the end of your code
function GUIAxesLegendFix(Handle,~,LegendLocation)try Handle.Contents(2).Location = LegendLocation; catch, endend
I just added try, catch to the callback to prevent giving any error during resizing in case you decide to add legend to the container later manually. I also attached an updated version of your sample code with method 2 solution. I suggest you to try the easier approach in the documentation and if you do not like the result, try the 2nd method.
Contact our installation team - it's free for students!
Best Answer