Asked by Locks
on 2 May 2013

Hi,

I intend to do a chart with two yaxis, the code is the following:

dates=datenum(dataSet(:,1));

%SPX SPX=dataSet(:,2);

%VIX VIX=dataSet(:,3);

plotyy(dates,SPX,dates,VIX);

%datevc divides the date in different columns, first colum is the year, %second the month and thrid the day d=datevec(dates);

%Takes just the year (first column) d=d(:,1);

%takes every year just once [a,idx]=unique(d(:,1),'first');

ylabel('VIX');

set(gca,'xtick',dates(idx),'xticklabel',a) ytix = get(gca,'YTick'); set(gca,'YTick',ytix(2:end));

This is working but unfortunately besides the years I have also the numeric date displayed on the x axis, how can I change that?

is there a way to make both y axis black instead of blue and green?

Answer by Azzi Abdelmalek
on 2 May 2013

Accepted Answer

use

[ax,h1,h2]=plotyy(dates,SPX,dates,VIX); set(ax(1),'ycolor','k') set(ax(2),'ycolor','k')

Locks
on 2 May 2013

perfect, thanks!!

Have you also a solution that there are no spaces between the plot and the y axis, in other words the plot should start at the left yaxis and ends at the richt yaxis

Azzi Abdelmalek
on 2 May 2013

set(ax,'xlim',[min(x) max(x)])

Locks
on 2 May 2013

perfect, thanks

Log in to comment.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments

Log in to comment.