Why does ycolor also color the xaxis?

4 visualizaciones (últimos 30 días)
Derek Neal
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'})

Respuesta aceptada

Dave B
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
Derek Neal
Derek Neal el 4 de Feb. de 2022
Editada: Derek Neal el 4 de Feb. de 2022
Fantastic. Thank you Dave! Yes, I decided to use yyaxis.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by