简体   繁体   中英

Matlab: auto axis range when you have two plots in the same figure

I use the following:

semilogy(x,P1);
hold on
semilogy(x,P2);    
hold off
axis([-inf,inf,0.0001,1])

No matter where I place the 'axis' command, it always give me a range suitable for P1, but not P2. Is there anything that can be done to have the auto ranging functionality to take both plots into account?

You could use the YLim property of your current axes, and set it to the minimal/maximal value between P1 and P2:

set(gca,'YLim',[min(P1,P2) max(P1,P2)]);

Is this what you mean?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM