Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of the second Y axis in the Matlab ( using new yyaxis tool)

Tags:

plot

matlab

I use matlab R2016a. I would like to make 2 Y axis of specific colours. I can not do it somehow.

(Manual says, that Y axis colour of the right side inherits colour of the first graph that appears under the definition of the right axis plots. The same should work with left axis plots.)

Here is the problem on a figure:

My left side is blue, while it should be green:

(my left side is blue, while it should be green):

Here is the code:

yyaxis left
hold all;
plot(bdates,normcdf(-DD_proxy_list),'r')
plot(bdates,normcdf(-DDstar_proxy_list),'b')
yyaxis right
plot(bdates,BBDP_slice,'g')
like image 819
Jenya Avatar asked Sep 11 '25 11:09

Jenya


1 Answers

For anyone else who comes across this like me, check these docs.

Assuming you want to change the right yyaxis and have plotted your data:

yyaxis right
ax = gca;
ax.YColor = 'g'

For older versions of MATLAB (pre-2014b) or those who dislike dot indexing:

yyaxis right 
set(gca,'YColor','g')
like image 77
IndefiniteBen Avatar answered Sep 13 '25 04:09

IndefiniteBen