Default date format for plot tick labels

8 Ansichten (letzte 30 Tage)
dormant
dormant am 5 Mai 2022
Beantwortet: Shivam am 3 Okt. 2023
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 Kommentar
dpb
dpb am 5 Mai 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'...

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shivam
Shivam am 3 Okt. 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.

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by