Can you use multiple formats for tick labels on an individual datetime axis?
1 view (last 30 days)
Show older comments
As an example, let's say I have a datetime object with a range of January 1, 2019 18:00 - January 2, 2019 10:00 on the x-axis of a plot. The default formatting creates tick labels as MMM dd, HH:mm. Each tick label includes the month and day. When there are around ten tick labels, I find this unnecessarily clutters the plot. I would like to have the first tick label display the month and day along with the time, with subsequent tick labels only showing the time, until the first tick label of the new day (i.e. when the data transitions from January 1 to January 2).
This would look something like:
Jan 1, 18:00 20:00 22:00 Jan 2, 00:00 02:00 04:00
and so on. It might be even better if the month and day were located directly under the time for those two tick labels. Is there any way to do this without manually changing the tick labels?
I know another way to remove some of the text would be to format the tick labels as HH:mm, which puts the date range, Jan 1, 2019-Jan 2, 2019, below the x-axis tick labels to the right side of the plot. I find this goes too far and may be confusing at first glance.
Thank you for any suggestions.
0 Comments
Answers (1)
See Also
Categories
Find more on Axis Labels 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!