Reputation: 723
I am using plotyy function in MATLAB. It is effectively 2 plots, each with 5 'lines'. I want the 5 lines to match in colors, but am not managing. I have tried various methods from set handle to colororder - see below.
The two variables, pk3... are vectors of 5 columns each.
[ax,h1,h2]= plotyy(2007:2050,pk3uco25,2007:2050,pk3ux45)
I have used the lines below to control the other properties, ...
set(h1,'linestyle', 'd','marker','*', 'markersize', 5) %variable 1
set(h2,'linestyle', '-', 'linewidth', 1.5) %variable 2
What I would like is that the first 5 lines, match the color of the second 5 lines. I have tried various things such as:
setting a colororder that repeats itself such that mycolororder{1:5,:} == mycolororder{6:10,:}
set(gca,'colororder',mycolororder); %
using a matrix of values
cols(1:5,1)={'color'};
cols(:,2)=get(h1,'color');
set(h2,cols{1:5,1},cols{1:5,2});
... and a few other things but no luck!
Upvotes: 3
Views: 7005
Reputation: 26069
In order to set h2
colors to be the same as h1
colors use this line:
set(h2, {'Color'}, get(h1,'Color'));
for example:
x=1:5;
y1=meshgrid(10:10:50,1:5);
y2=y1+1;
[ax,h1,h2]= plotyy(x,y1,x,y2);
set(h2, {'Color'},get(h1,'Color'));
Upvotes: 3