Borrar filtros
Borrar filtros

Why does ycolor also color the xaxis?

10 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.

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):
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:
yyaxis left
yyaxis right
  3 comentarios
Dave B
Dave B el 2 de Feb. de 2022
Ah I didn't get it from your initial question, but I see now...this is an awkward interaction of plotyy and bar.
What you're seeing is the red 'baseline' running over the top of the black XColor.
Bar charts have a BaseLine, which is often the bottom of your y axis, but doesn't have to be that way. The baseline takes on the color of the associated y axis, because it sort-of acts as a big YTick. In a normal (not-plotyy) Bar chart, the baseline would end up underneath the x-axis, so you wouldn't see it. But in the plotyy case, the right baseline ends up on top of the x-axis associated with the left. Of course, all of this is why we made yyaxis, so we could avoid the 'trick' of stacking two axes on top of eachother and all the problems it causes.
In any case, you can set the baseline color directly (but I hope you'll use yyaxis instead!):
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)


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!

Translated by