Dear all,
I am experiencing a problem with the datetick function. I am working on Matlab R2014a and the problem is the following.
I have some time series data, which I want to plot and I would like to have the x-ticks in yyyy-qq format. For this purpose I am using the functions datenum and datetick. However, dateticks generates the x-ticks sometimes inaccurately; it misses sometimes certain quarters and jumps directly to the next (e.g. the ticks are 2015-Q4 2016-Q1 2016-Q2 2016-Q3 2017-Q1), so 2016-Q4 is apparently missing. However, the space between the ticks is equal, so this must be an error.
This code reproduces the problem:
%%Problem with x-ticks using datetick
data_cpi=0.2+randn(229,1);startDate = datenum(1998,12,1);endDate = datenum(2017,12,1);month = linspace(startDate,endDate,size(data_cpi,1))';figureplot(month,data_cpi)xlim([month(end-36) month(end)])datetick('x','yyyy-qq','keepticks','keeplimits')
Is this a bug and how could I fix this problem?
Thanks for the help in advance!
Best,
Diego
Best Answer