MATLAB Answers


show month and year of a dataseries on the x axis

Asked by Locks
on 5 May 2013
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
%Takes just the year (first column)
%takes every year just once
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
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?


Sign in to comment.

2 Answers

Answer by Shashank Prasanna on 6 May 2013
 Accepted Answer

Try using the following submission on FEX:


I there a way without FEX? Others should be able to run the code as well and if they need to download the FEX first that would make it more complicated
1) Give the FEX functions which is really 2 files along with your code, to others.
2) Create a subfunction in your code from the code in the dynamic datetick and distribute one file, instead of asking the end users to download it.
3) Go through the FEX submission and minimize the code specific to your application and include it your self.
ok, thanks

Sign in to comment.

Answer by the cyclist
on 5 May 2013

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.

  1 Comment

thanks, what I just do see is how I can adapt the existing code using those elements. could you give me a hint?

Sign in to comment.