matlab 中 hold on 和hold off的使用

hold on 使当前轴及图形保持而不被刷新,准备接受此后将绘制的图形,多图共存

hold off 使当前轴及图形不在具备被刷新的性质,新图出现时,取消原图

hold on 在当前图的轴(坐标系)中画了一幅图,再画另一幅图时,原来的图还在,与新图共存,都看得到
close all
x=0:2:100;
y1=2*x;
y2=3*x;
y3=3.5*x;
ph1=plot(x,y1,'r-'); hold on
ph2=plot(x,y2,'g--');
ph3=plot(x,y3,'b:');
title('fake data')
xlabel('my x data');
ylabel('my y data');
th1=text(x(13),y1(13),'red line');
th2=text(x(15),y2(15),'green line');
th3=text(x(17),y3(17),'blue line');
set(th1,'Color','r');
set(th2,'Color','g');
set(th3,'Color','b')
lh=legend([ph1 ph2 ph3],{'x2';'x3';'x3.5'})
matlab <wbr>中 <wbr>hold <wbr>on <wbr>和hold <wbr>off的使用

hold off 在当前图的轴(坐标系)中画了一幅图,此时,状态是hold off,则再画另一幅图时,原来的图就看不到了,在轴上绘制的是新图,原图被替换了
close all
x=0:2:100;
y1=2*x;
y2=3*x;
y3=3.5*x;
ph1=plot(x,y1,'r-'); hold off
ph2=plot(x,y2,'g--');
ph3=plot(x,y3,'b:');
title('fake data')
xlabel('my x data');
ylabel('my y data');
th1=text(x(13),y1(13),'red line');
th2=text(x(15),y2(15),'green line');
th3=text(x(17),y3(17),'blue line');
set(th1,'Color','r');
set(th2,'Color','g');
set(th3,'Color','b')
lh=legend([ph1 ph2 ph3],{'x2';'x3';'x3.5'})
matlab <wbr>中 <wbr>hold <wbr>on <wbr>和hold <wbr>off的使用

 
posted @ 2020-05-08 10:20  yongbin-H  阅读(1555)  评论(0编辑  收藏  举报