How do you rotate datetick labels?

4 ビュー (過去 30 日間)
Audra Kiesling
Audra Kiesling 2013 年 4 月 5 日
コメント済み: Peter Perkins 2019 年 3 月 11 日
I have a plot that spans a little over the course of an entire day. I need to label the x axis in 30 minute increments, using the datetick function. I have already been able to figure out how to do that, but once I do, all of the labels are bunched up on one another. I need to rotate my datetick labels 45-90 degrees. I've found various articles talking about this, but have not had any luck implementing them in to my code.

回答 (1 件)

Mahabub Alam
Mahabub Alam 2019 年 3 月 8 日
startDate = datenum('02-01-1962')
endDate = datenum('11-15-2012')
xData = linspace(startDate,endDate,50)
stem(xData,rand(1,50))
set(gca,'XTickLabelRotation',45)
datetick('x','yyyy','keeplimits')
Note: I do not know whether it is relevant to answer this questions now.
  1 件のコメント
Peter Perkins
Peter Perkins 2019 年 3 月 11 日
Indeed it probably is not, as MATLAB R2014b introduced datetime, which among other things makes plotting much nicer than datenum/datetick.
startDate = datetime(1962,2,1)
endDate = datetime(2012,11,15)
xData = linspace(startDate,endDate,50)
stem(xData,rand(1,50))
set(gca,'XTickLabelRotation',45)
untitled.png

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

カテゴリ

Help Center および File ExchangeAxes Appearance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by