Dates beside the axis when plotting datetime
2 views (last 30 days)
Show older comments
Hiroyuki Kubota
on 22 Sep 2020
Edited: Benjamin Kraus
on 26 Apr 2024
I'm trying to plot changes on a specific date of a long intraday data, and want to show (1) only the time and erase the date which appears beside the axis, or (2) change the language of the date beside the axis.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/364231/image.png)
2 Comments
Walter Roberson
on 22 Sep 2020
There is a private property named ScaleFormat_I that is under the XAxis property of the axes.
Unfortunately, it does not appear to be possible to set the property, and the details of constructing datetime rulers is hidden inside a .p file toolbox/matlab/graphics/axis/+matlab/+graphics/+axis/+decorator/DatetimeRuler.p
Benjamin Kraus
on 26 Apr 2024
Edited: Benjamin Kraus
on 26 Apr 2024
@Walter Roberson: Starting in R2024a, the ScaleFormat_I property has been replaced by a documented (and wirtable) SecondaryLabelFormat property.
Accepted Answer
Abby Skofield
on 20 Sep 2023
Edited: Adam Danz
on 18 Oct 2023
Starting in R2023b, you can use the new family of secondary label functions (e.g. xsecondarylabel) to toggle the visiblity of the secondary label off.
t = datetime('September 1, 2023'):days(1):(datetime('now')+days(90));
y = cumsum(randn(size(t)));
plot(t,y)
title('Fall 2023')
xsecondarylabel('Visible','off')
You can also use the new functions to add custom secondary labels.
ysecondarylabel('USD, millions')
For more info and demos on secondary labels, see the Graphics and App Building blog article below.
0 Comments
More Answers (1)
Seth Furman
on 21 Oct 2020
1) The date information can be hidden by setting the TickLabelsMode to 'manual' on the DatetimeRuler.
ax = gca;
ax.XAxis.TickLabelsMode = 'manual';
2) The default input locale for datetimes can be changed in the Preferences dialog box (i.e. Preferences > Command Window > Datetime format > Locale).
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!