Default date format for plot tick labels
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2022-5-5
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'...
回答(1 个)
Shivam
2023-10-3
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!