How to hide representative duration at datetime X-axis plot?
조회 수: 13 (최근 30일)
이전 댓글 표시
How to remove/hide representative duration at datetime X-axis plot under auto-mode condition(XTickLabelMode)?
댓글 수: 0
채택된 답변
Adam Danz
2023년 9월 20일
Starting in MATLAB R2023b, you can add, remove, or update the secondary labels using
Demo
plot(datetime(2014,6,9)+days(0:9), 0:9)
xsecondarylabel(Visible="off")
댓글 수: 2
Benjamin Kraus
2024년 4월 26일
Starting in R2024a you have even more control over the secondary label.
- You can use the xsecondarylabel command (introduced in R2023b) to hide the label (set Visible='off') or set a manual string to hard-code your secondary label.
- Starting in R2024a, you can now set the SecondaryLabelFormat property on the x-axis if you want to change the formatting of the label without losing the automatic nature.
ax = axes;
plot(ax, datetime(2014,6,9)+days(0:9), 0:9);
ax.XAxis.SecondaryLabelFormat = 'yyyy-MM';
추가 답변 (2개)
Ameer Hamza
2020년 10월 8일
편집: Ameer Hamza
2020년 10월 8일
You can do it by running the following statements.
ax = gca;
ax.XTickLabel = ax.XTickLabel;
or
ax = gca;
ax.XTickLabelMode = 'manual';
댓글 수: 4
Ameer Hamza
2020년 10월 8일
I think for normal visualization, when you need to zoom on the axes, the date might not be an issue. Just turn it off when printing or saving the image.
Seth Furman
2020년 10월 12일
편집: Seth Furman
2020년 10월 12일
If you just want the duration data for the time of day on the x-axis, you can use the timeofday method for datetime.
>> x = datetime('today'):hours(1):datetime('today')+hours(10);
>> y = 0:10;
>> plot(timeofday(x),y)
>> xtickformat('hh:mm')
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!