In a MatLab plot, when is 'box on' the default, and when is it not?

조회 수: 7 (최근 30일)
Euan
Euan 2012년 12월 7일
Two very similar figure codes furnich plots with and without a box. Fixed by setting 'nox on'
  댓글 수: 4
Euan
Euan 2012년 12월 7일
편집: Matt Fig 2012년 12월 7일
Thanks, Matt fig. that helps. But this code, with 'stairs', leaves box off:
figure
xlim([0 4])
% semilogx(MCrange,logncdf(MCrange,0,sigg),'-b')
hold on
stairs(renorm,(1/ndat)*[1:ndat],'-k')
hold on
plot(MCrange,logncdf(MCrange,0,sigg),'-b')
xlabel('normalised Mg/Ca')
ylabel('cumulative probability')
legend('normalised data','log-normal model','Location','Southeast')
Matt Fig
Matt Fig 2012년 12월 7일
편집: Matt Fig 2012년 12월 7일
It would be helpful if you comment on a particular answer when addressing that answer. For example, under my answer, there is a box that says "Comment" for such use...

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt Fig
Matt Fig 2012년 12월 7일
편집: Matt Fig 2012년 12월 7일
I see you were not just using the PLOT function.
The STAIRS function sets the box to on (line 99 in stairs.m). Thus as I said, the default is box off, but this is a specialty function that sets box on.
Other specialized plotting functions may do the same thing.
  댓글 수: 2
Matt Fig
Matt Fig 2012년 12월 7일
Euan comments:
Thanks, Matt fig. that helps. But this code, with 'stairs', leaves box off:
figure
xlim([0 4])
% semilogx(MCrange,logncdf(MCrange,0,sigg),'-b')
hold on
stairs(renorm,(1/ndat)*[1:ndat],'-k')
hold on
plot(MCrange,logncdf(MCrange,0,sigg),'-b')
xlabel('normalised Mg/Ca')
ylabel('cumulative probability')
legend('normalised data','log-normal model','Location','Southeast')
Matt Fig
Matt Fig 2012년 12월 7일
편집: Matt Fig 2012년 12월 7일
The difference is that here you have set the hold state of the axes to on before calling STAIRS. If you look at the line of code I referenced above in stairs.m you will see this:
if ~hold_state
set(cax,'NextPlot',next);
set(cax,'Box','on');
end
Thus STAIRS checks to see if the current axes is held. If not, it sets the box on.
All of this is interesting, but unless you want to memorize the behavior of all MATLAB's special plotting functions I recommend calling BOX the way you want it after any plotting takes place.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by