Default date format for plot tick labels
8 views (last 30 days)
Show older comments
Is it possible to set a default format for datetick labels? Sometimes MATLAB gives me "mm/dd" when I prefer "dd/mm".
I could easily set this manually for every plot, but it's easy to overlook and I often send plots to people with the wrong date format.
1 Comment
dpb
on 5 May 2022
I'm sure there probaby is, but I can't figure out how/where to try to address it...the documentation on default properties has always led me down a rabbit hole from which I've never found my way to the tea party...
It's particularly troublesome for the DatetimeRuler object which appears by magic when you plot into an axes with a datetime variable. If/when you create a new axis, it is always the default numeric axis.
I seem to recall S Lord showing an example at one time of a magic incantation, but I don't reall what it was nor could I find it in a quick search...
But short story is I couldn't figure out a default property name that could assign nor recall...I'm sure they have to exist, but how to get/set I can't tell ya'...
Answers (1)
Shivam
on 3 Oct 2023
Hi,
As per my understanding, you are trying to make plots where you want to avoid setting specific datetick labels for each plot manually.
To achieve this, you can make a function that plots the data and sets the "datetick" format for the corresponding plot. You can follow the below workaround.
function myPlot(x, y)
plot(x, y);
datetick('x', 'dd/mm', 'keepticks');
end
I hope it helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!