Mega Search
23.2 Million


Sign Up

Make a donation  
Combining yyplots with multiple colors  
News Group: comp.soft-sys.matlab

Hi! I have some serious trouble getting this easy plot done. Can't seem to figure it out. Hope someone can help!

I have four graphs that I would like to plot in a yyplot. The coefficients Q and A on each side and the geometry input on the x-axis. I would like both the Q-graphs to be blue and A to be red, and eventually play with the linestyle. The problem is that my axis are constantly mixed up and overlaying each other so not giving the right color. Thanks! 

Script: 

sq_size_sm = [0 0.1 0.25];
tr_size = [0 0.1 0.25];

A2_squares_sm = [262.8 215.8 197.3];
A2_triangles = [262.8 181.2 198.3];
Q_squares_sm = [157.4 148.9 127.2 ];
Q_triangles = [157.4 116.4 128.9 ];

figure
[ax,h1,h2] = plotyy(tr_size,Q_triangles,tr_size,A2_triangles);
set(h1,'Color','[1 0 0]')
set(h2,'Color','[0 0 1]')
hold on
[bx,g1,g2] = plotyy(sq_size_sm,Q_squares_sm,sq_size_sm,A2_squares_sm);
set(g1,'Color','[1 0 0]')
set(g2,'Color','[0 0 1]')
title('Performance coefficients');
xlabel('Size of squares and triangles [mm]');
ax = gca;
    set(ax,'XTick',[0 0.1 0.25]);
    set(ax,'XTickLabel',{'0','0.1','0.25'});
legend([h1,h2,g1,g2],'Q factor [-]','A (250-2k) [-]');
grid on

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 29-Aug-2016, at 9:37 AM EST
From: Gommer
 
Re: Combining yyplots with multiple colors  
News Group: comp.soft-sys.matlab
On 08/29/2016 4:37 AM, Gommer wrote:
....

> ... The problem is that my axis are
> constantly mixed up ...

....

> [ax,h1,h2] = plotyy(tr_size,Q_triangles,tr_size,A2_triangles);
> set(h1,'Color','[1 0 0]')
> set(h2,'Color','[0 0 1]')
> hold on
> [bx,g1,g2] = plotyy(sq_size_sm,Q_squares_sm,sq_size_sm,A2_squares_sm);

NO!  Don't make another pair of axes; just add to the existing ones with 
LINE or augment the '[X|Y]Data' properties.

....

> ax = gca;

Double NO!  Now you've compounded your troubles by overwriting the 
original axes handles...


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 29-Aug-2016, at 8:23 AM EST
From: dpb