Why does ycolor also color the xaxis?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Derek Neal
el 1 de Feb. de 2022
Editada: Derek Neal
el 4 de Feb. de 2022
After using plotyy, the ycolor command turns the left yaxis blue, right yaxis red and the xaxis red. I want xaxis to remain black. Using xcolor has no effect.
set(gca,{'ycolor'},{'b';'r'})
0 comentarios
Respuesta aceptada
Dave B
el 1 de Feb. de 2022
With plotyy, you can use the output arguments to get access to the 'right' axes. Setting the property on gca would just affect the left axis (and I'd have expected an error with the syntax you provided):
ax=plotyy(1:10,1:10,1:10,ones(1,10));
set(ax(1),'YColor','b');
set(ax(2),'YColor','r');
Note that as you'll see on the plotyy documentation page, plotyy is not recommended, and we suggest you use yyaxis instead. Here is the equivalent code using yyaxis:
figure
yyaxis left
plot(1:10,1:10);
set(gca,'YColor','b')
yyaxis right
plot(1:10,ones(1,10));
set(gca,'YColor','r')
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Two y-axis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!