필터 지우기
필터 지우기

anyway to add grid based on right yyaxis

조회 수: 48 (최근 30일)
Yu Li
Yu Li 2018년 12월 18일
답변: Matthew Wiser 2022년 10월 25일
Hi:
is there anyway to add grid based on right yyaxis instead of the left one?
Thanks!
Yu

채택된 답변

madhan ravi
madhan ravi 2018년 12월 19일
편집: madhan ravi 2018년 12월 19일
As Cris LaPierre as already stated the precise algorithm , what you can do is you can just swap the yyaxis right to left and vice versa thereby satisfying your needs .
Or try this example using plotyy() and then follow it to your case:
[AX,H1,H2] =plotyy((1:10),(1:10),(1:10),(1:10).^2);
AX(1).YTick=1:10; % make sure both the ticks have the same number of points to align them equally
AX(2).YTick=0:10:100;
AX(1).XGrid='on';
AX(2).XGrid='on';
AX(2).YGrid='on'; % grab the second axis handle and add grid lines to it
% AX(1).YMinorGrid='off';
AX(2).LineWidth=2;
  댓글 수: 6
Yu Li
Yu Li 2018년 12월 19일
That function is not recommended after 2016a.
Mathworks has announced 2019 several days ago.
Thank you!
Yu
madhan ravi
madhan ravi 2018년 12월 19일
Your welcome! , hopefully the option is added in the latter version.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Cris LaPierre
Cris LaPierre 2018년 12월 19일
It does not appear to be possible to add a grid line to the right axis when plotting using yyaxis. There are methods available in Answers if you use plotyy.
My source is the documentation page for yyaxis > Algorithms:
Grid Lines
Grid lines correspond with the tick mark locations along the left y-axis.

Matthew Wiser
Matthew Wiser 2022년 10월 25일
Well, then swap your plotting variables so that the variable you want to have aligned grid lines is on the left.
Not being a smart alec, but if you can't beat the system, then use the system.

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by