MATLAB: Anyway to add grid based on right yyaxis

plotyy right axis gridright yyaxis grid

Hi:
is there anyway to add grid based on right yyaxis instead of the left one?
Thanks!
Yu

Best Answer

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;