フィルターのクリア

How to hide representative duration at datetime X-axis plot?

17 ビュー (過去 30 日間)
Euigyeong Hong
Euigyeong Hong 2020 年 10 月 8 日
コメント済み: Benjamin Kraus 2024 年 4 月 26 日 19:19
How to remove/hide representative duration at datetime X-axis plot under auto-mode condition(XTickLabelMode)?

採用された回答

Adam Danz
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 件のコメント
Euigyeong Hong
Euigyeong Hong 2023 年 9 月 21 日
It is good news to me but I am still stuck on 2021b version.
Thank you for caring about this even after 3 years.
Benjamin Kraus
Benjamin Kraus 2024 年 4 月 26 日 19:19
I realize @Euigyeong Hong is stuck on R2021b, but for others who come across this answer:
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
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 件のコメント
Euigyeong Hong
Euigyeong Hong 2020 年 10 月 8 日
That's too bad. It seems to need an option.
Thank you, Ameer!!
Ameer Hamza
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
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')
  1 件のコメント
Euigyeong Hong
Euigyeong Hong 2020 年 10 月 12 日
編集済み: Euigyeong Hong 2020 年 10 月 12 日
Thanks, Seth.
But I am finding to see the plot by auto-format mode because when I zoom in to short time it is easy to see "hh:mm:ss.SSS" format by itself. After checking the plot, I copied the figure, but the number of figure was 20~30, so I was unhappy.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by