multiple Y axes second axes blocking/obscuring first

i'm not sure what's going on here. you can see the axes for both and both axes re-scale when the lines are plotted. you just can't see the line for the "first" axis. using some of the example code from http://www.mathworks.com/help/techdoc/creating_plots/f1-11215.html
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
figure('position',[1 1 6*72 8*72])
ax1=axes;
ax2=axes;
set(ax2,'YAxisLocation','right');
hl1 = line(x1,y1,'Color','r','Parent',ax1);
this also does it:
figure;
hl1 = line(x1,y1,'Color','r');
ax2 = axes('Position',get(gca,'Position'),'YAxisLocation','right');
which strikes me as EXTREMELY similar to the example. it seems to be dependent upon position and that position can't be any old vector but actually grabbed from gca or ax1, etc? still confused. i need to be able to draw the axes independently of using line()
if i redo the call to line(ax1) it plots correctly. maybe it's a refresh thing? do i have to refresh ax1, somehow? i set() stuff on axes pretty rampantly in my code, i can't be re-calling the plotting stuff everytime...
ideas? i'm in 7.9.1.671 (R2009b) Service Pack 1
thanks

 Respuesta aceptada

Eric
Eric el 8 de Dic. de 2011

0 votos

OH! 'color','none'
kinda strange that that's required, but okay.

Más respuestas (0)

Categorías

Preguntada:

el 8 de Dic. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by