Default date format for plot tick labels

8 visualizaciones (últimos 30 días)
dormant
dormant el 5 de Mayo de 2022
Respondida: Shivam el 3 de Oct. de 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 comentario
dpb
dpb el 5 de Mayo de 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'...

Iniciar sesión para comentar.

Respuestas (1)

Shivam
Shivam el 3 de Oct. de 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.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by