Set Y axis ticks Red but not grid lines

5 views (last 30 days)
Jason
Jason on 10 Oct 2014
Edited: dpb on 11 Oct 2014
I am plotting a 2 y axis plot using plotyy. Each point is plotted inside a loop. I want the first Y axis (FM) to have the Y-axis tick numbers in red but not the horizontal grid lines. so is it possible to keep tgridlines blue, but change the numbers on the yaxis to red.
I changed the yaxis 1 label to red OK.
[AX,H1,H2] = plotyy(A,B,A,C,'plot');
set(H1,'LineStyle','--', 'color', 'r','Marker','*');
set(get(AX(1),'Ylabel'),'String','FM','FontSize',8,'Color','red');
Thanks Jason

Answers (1)

dpb
dpb on 10 Oct 2014
Edited: dpb on 11 Oct 2014
You'll have to use text to write the tick labels to do that, set ting the 'yticklabel' property to []. Or, alternatively, change the 'xgrid','off' and draw the grid lines explicitly in blue letting the axis become red.
ADDENDUM:
A recent thread shows the basics plus some additional niceties of using the TeX interpreter w/ tick labels thus written that can't do w/ the '_ticklabel' property. Plus another poster referenced a File Exchange submittal that may be of interest...
Happened to be for log axes, but that's really immaterial to the solution.

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!