Expand subplot to fill entire figure

15 次查看(过去 30 天)
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
?

回答(1 个)

Walter Roberson
Walter Roberson 2011-6-14
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!

Translated by