Expand subplot to fill entire figure

38 views (last 30 days)
Tobin Fricke
Tobin Fricke on 14 Jun 2011
I often plot Bode plots to plot the magnitude and phase of a complex function:
ax = subplot(2,1,1)
semilogx(f, db(H)); % plot the magnitude
ax(2) = subplot(2,1,2);
semilogx(f, angle(H)*180/pi); % plot the phase
Often I want to just look at the magnitude while ignoring the phase, but it would be nicer if this didn't mean commenting out the subplot commands.
Is there a simple way to temporarily expand one of these subplots to fill the entire figure, as if it were just a subplot(1,1,1)? Something like:
focus(ax(1)); % just look at ax(1)
restore(ax); % return to the view of two subplots

Answers (1)

Walter Roberson
Walter Roberson on 14 Jun 2011
oldunits = get(ax(1), 'Units');
oldpos = get(ax(1), 'Position');
set(ax(1), 'Units', 'normal', 'Position', [0 0 1 1]);
Then later
set(ax(1), 'Units', oldunits, 'Position', oldpos);
If you were enthusiastic enough, you could store the old units and position via setappdata()


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!