modifying colours of plotyy axis within a subplot

2 views (last 30 days)
OK so I have subplot with two plotyy, I can plot subplot(2,1,1) fine, but for the subplot(2,1,2) I am plotting two different types of data, and to make this clear I would like to change the colors of the ylabels and the yticks and ytick labels, but I'm having a few problems. What I have so far is:
subplot(2,1,2)
[haxes,hline1,hline2]=plotyy(DayTime,LOTMEAN,DayTime, LORAINFALL,'line','bar');
axes(haxes(1))
ylabel('Temperature (/circC)','Color','r');%which is fine
set(hline1('Color','r')); %but then I get an error when I try to set the line colour - anyone know why?
??? Index exceeds matrix dimensions.
Second problem, is I can't get the YColor to change
h=axis(YColor,'r'); %this is as written in help file
??? Undefined function or variable 'YColor'.
I ended up doing it in the Figure Properties in the GUI, but I can't figure out how to do this to the second axis, either in code or in Figure Properties. Is there a step by step guide for changing figure properties anywhere that might help? The help files don't explain things fully.
I would much appreciate any help to clear the confusion!!
Many thanks,
Cat

Answers (1)

Image Analyst
Image Analyst on 11 Apr 2012
Try putting it in single quotes:
h=axis('YColor','r');
  3 Comments
Image Analyst
Image Analyst on 11 Apr 2012
Oh well. This is what I saw in my help:
Properties That Control the X-, Y-, or Z-Axis
XColor, YColor, ZColor
ColorSpec
Color of axis lines. A three-element vector specifying an RGB triple, or a predefined MATLAB color string. This property determines the color of the axis lines, tick marks, tick mark labels, and the axis grid lines of the respective x-, y-, and z-axis. The default axis color is black. See ColorSpec for details on specifying colors.
Maybe try passing in a numerical color instead of a special color:
h=axis('YColor', [1 0 0]); % Red = [1 0 0]

Sign in to comment.

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!