Search code examples
matlabuser-interfaceresizeaxes

Axes takes up entire screen in MATLAB GUI


There must be a simple answer to this. I cannot really find a suitable response after a lot of searching.

This is what I want to make using the GUIDE tool.

enter image description here

This is what I get. (Note: the plot is made using the subplot function)

enter image description here

What am I doing wrong? Shouldn't the plot simply fit into the predefined 'axes1' rectangle from the GUIDE interface?


Solution

  • If you use the subplot function within the GUI it will override the axes defined using GUIDE. Instead it is best to plot two separate axes.

    %this will plot axes 1    
    axes(handles.axes1)
    plot(x,y)
    title('Title of Axes 1'
    ylabel('y Label of Axes 1')
    xlabel('x Label of Axes 1')
    
    %this will plot axes 2
    axes(handles.axes2)
    plot(x,y)
    title('Title of Axes 2'
    ylabel('y Label of Axes 2')
    xlabel('x Label of Axes 2')