MATLAB Answers

Euan
0

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

Euan
さんによって質問されました 2012 年 12 月 7 日
Two very similar figure codes furnich plots with and without a box. Fixed by setting 'nox on'

  4 件のコメント

Euan
2012 年 12 月 7 日
figure
stairs(xt,Ft,'-k')
hold on
chsum=intvl*sum(ps);
ps=(1/chsum)*ps;
mu=sum(ps.*xp)*intvl;
dev=xp-mu*ones(nxp,1);
var=sum(ps.*dev.^2)*intvl;
sigfac=var/mu^2;
sig=sqrt(log(1+sigfac));
muln=log(mu)-0.5*sig^2;
mui=[muln-0.1:.05:muln+.1];
nmui=length(mui);
stemp0=log(stemp(2:nsamp+1)); % to match spachy
mudat=sum(stemp0.*spachy)/sum(spachy);
tdev=stemp0-mudat*ones(nsamp,1);
vardat=sum(spachy.*tdev.^2)/sum(spachy);
KScompare=logncdf(stemp,mudat,sqrt(vardat));
[h,p,ksstat,cv] = kstest(cum,[stemp,KScompare]);
KSdiff=abs(cum-KScompare);
plot(xp,logncdf(xp,mudat,sqrt(vardat)),'-k')%,'color',col(cind,1:3))
xlabel(' temperature ^oC')
ylabel('cumulative probability')
legend('data','lognormal model','Location','Southeast')
Euan
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')
Login_Name
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...

サインイン to comment.

タグ

製品

1 件の回答

回答者: Login_Name
2012 年 12 月 7 日
編集済み: Login_Name
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 件のコメント

Login_Name
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')
Login_Name
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.

サインイン to comment.



Translated by