Default date format for plot tick labels

조회 수: 8 (최근 30일)
dormant
dormant 2022년 5월 5일
답변: Shivam 2023년 10월 3일
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
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
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.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by