![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199372/image.png)
anyway to add grid based on right yyaxis
48 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yu Li
am 18 Dez. 2018
Beantwortet: Matthew Wiser
am 25 Okt. 2022
Hi:
is there anyway to add grid based on right yyaxis instead of the left one?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199349/image.jpeg)
Thanks!
Yu
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 19 Dez. 2018
Bearbeitet: madhan ravi
am 19 Dez. 2018
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 .
[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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199372/image.png)
6 Kommentare
Weitere Antworten (2)
Cris LaPierre
am 19 Dez. 2018
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.
Grid Lines
Grid lines correspond with the tick mark locations along the left y-axis.
0 Kommentare
Matthew Wiser
am 25 Okt. 2022
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!