Expand subplot to fill entire figure

조회 수: 18 (최근 30일)
Tobin Fricke
Tobin Fricke 2011년 6월 14일
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()

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by