How do I force subplots to remain square when I maximize a figure?
33 views (last 30 days)
Show older comments
I have a figure which has four subplots in it. The axes of the subplots are square when plotted. However when the figure is maximized, the subplots are no longer square.
An example is provided below:
figureHandle = figure;
subplot(2,2,1), plot(exp(1:100))
subplot(2,2,2), plot(sin(0:pi/100:4*pi))
subplot(2,2,3), plot(log(0:30))
subplot(2,2,4), plot(1:40)
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This is an expected behavior. By default, the stretch-to-fill behavior for axes is enabled. By extracting the axes handles of all subplots and setting them to square, the desired behavior can be achieved.
An example is provided below:
% Extract axes handles of all subplots from the figure
axesHandles = findobj(get(figureHandle,'Children'), 'flat','Type','axes');
% Set the axis property to square
axis(axesHandles,'square')
0 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!