xticklabels function for more than 11 labels ?

3 views (last 30 days)
Hello everyone ,
I need to use the function "xticklabels" for labeling the x-axis this is my code:
figure (1)
but the figure display only till 'nov' how can I include the last one ?
Thank you.

Accepted Answer

Jan on 10 Jul 2018
It is smarter to avoid the hard coding to set the names of the months, but to use datetick to display the names dynamically and automatically adjusted to the data.
Steven Lord
Steven Lord on 10 Jul 2018
Instead of using datetick, consider plotting a datetime array.
startOfYear = dateshift(datetime('today'), 'start', 'year');
randomDays = randi([0 364], 1, 20);
D = startOfYear + days(sort(randomDays));
D.Format = 'MMM dd';
plot(D, 1:20, '-o')

Sign in to comment.

More Answers (1)

Mandeep  Singh
Mandeep Singh on 10 Jul 2018
From my understanding of the problem, you could specify the xticks before xticklabel to get the desired output . Try the following example snippet:
The value of the xticks can be varied according to the data you are plotting.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!