How to set front and back lines on plot with yyaxis left and right
이전 댓글 표시
Hi,
I have a situation where I would like the plot of the right axis (yyaxis right) to be "under" the plot from the left axis (yyaxis left). Here is a simplified code sample:
x = 1:0.001:100;
y = sin(x);
y2 = awgn(y,2); % Add noise
figure(1)
yyaxis right
p2 = plot(x,y2);
yyaxis left
p1 = plot(x,y);
legend([p2,p1],'Curve that should be behind','curve that should be in front')
The problem (I think) is that the left axis is called first no matter what. So even if I specify the right axis first, the left curve will still be under the one on the right. I am not able to change this using children of the figure (specify the right axis to be plotted first instead of left).
In my application, I would really like to keep the curve on their side, because it would be uniform with other figure in my article. What happens is that the curve on the right is noisier than the one on the left, which is why I would like to have it under in this format (using yyaxis).
Thanks in advance for any ideas you could have!
댓글 수: 1
Adam Danz
2022년 3월 2일
I'll add your thread to the list....
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



