I have this code which displays the respective year on the x axis
%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');
[ax,h1,h2]=plotyy(dates,SPX,dates,VIX); set(ax(1),'ycolor','k') set(ax(2),'ycolor','k') set(ax,'xtick',dates(idx),'xticklabel',a)
this worked well for a plot I needed, but I would like to plot a shorter time series where I can see the month as well as the year on the x axis
I have found this: http://www.mathworks.ch/ch/help/matlab/ref/datetick.html
but there are only months on the x axis, what do I need to ammend in my code to be able to see both, month and year?
No products are associated with this question.
Try using the following submission on FEX:
If you click on the dateFormat link in the Input Arguments section of that help page you mention, so you will see that there are many different ways to format the labels, including some that show both month and year.
Play games and win prizes!Learn more