Adding to a legend after each iteration

前端 未结 5 1623
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 15:13

I run

loglog(x,y);
legend(\'First script\');

from the first script. Then, hold on;. I run a similar second script. I see two g

5条回答
  •  自闭症患者
    2020-12-17 15:51

    The simplest way is:

    hold all;
    p1=plot(1:10,1:10);  
    legend(p1,'1');  % in this way plot(x,y) is saved as variable p1 with name '1'   
    p2=plot(1:10,11:20); % different data set
    
    legend(p2,'2');  
    legend(gca,'off');    
    legend('show');
    

    This is connection of few methods, it's very simple and it could be use everywhere.

提交回复
热议问题