Reputation: 542
I'm creating a simple GUI in MATLAB and I'm trying to create a figure that contains a 2d plot on an axes, all is working well, but I have a rough time trying to figure out how to fix the position of the axes/plot.
The axes seems to scale with the figure window size. If I maximize the figure on my screen, the axes is maximized within, etc. What I want to accomplish is to have a row of buttons beneath the plot on the same figure as the plot, basically an area of 50 (ish) pixels tall that the plot does not encroach on. I know how to do this in HTML, but I can't figure out a good way in MATLAB.
Any alternative approaches would also be greatly appreciated.
Upvotes: 1
Views: 288
Reputation: 30579
Change the units
of the axes to anything other than 'normalized'
, like 'pixels'
. Then it won't automatically resize with the figure. From this documentation page:
When you create a graph, MATLAB® creates an axes to display the graph. The axes is sized to fit in the figure and automatically resizes as you resize the figure. MATLAB applies the automatic resize behavior only when the axes Units property is set to normalized (the default).
Use set(gca,'Position',pos)
where pos = [x y w h]
to set the position and size of the axes in the units you chose.
See this answer for an example and a function for holding an axis size once you have it in place.
Upvotes: 1