Jenya
Jenya

Reputation: 43

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

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')

Upvotes: 4

Views: 17282

Answers (2)

IndefiniteBen
IndefiniteBen

Reputation: 81

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')

Upvotes: 6

TCS
TCS

Reputation: 1

In case anyone else comes across this post,

yyaxis right
plot(bdates,BBDP_slice,'g')
set(gca,

Upvotes: -3

Related Questions