Using hold all with plotyy
显示 更早的评论
When I use hold all with plot, all the colors of the lines in the figure can be different automaticly, but when I use it with plotyy , it does not work that well, as there are two handles to hold. So how can I fix it? Thanks. My code is as follows,
x1 = 0:0.01:10;
x2 = 0:1:10;
y1 = sin(x1);
y2 = sin(x2);
y3 = 10*cos(x1/2);
y4 = 10*cos(x2/2);
y5 = x2;
figure
[hAx,hL1,hL2] = plotyy(x1,y1,x2,y2);
set(hAx(1),'YLimMode','auto');
set(hAx(2),'YLimMode','auto');
set(hAx(1),'YTickMode','auto');
set(hAx(2),'YTickMode','auto');
hold(hAx(1),'all');%hold all
hold(hAx(2),'all') ;
plot(hAx(1),x2,y4);
plot(hAx(1),x1,y3);
plot(hAx(2),x2,y5);
hold(hAx(1),'off');%hold off
hold(hAx(2),'off') ;
回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!