Hello, I'm trying to create a plot where the x axis is a range of dates from Sept. 8th to Oct. 25th. I do not have any date matrix already in the code that I'm trying to convert. I was hoping to have the x tick marks as weekly occurances, or Mondays, or whatever works out easiest b/c I feel every day would look to cluttered. The city names are a series of values for each particular day. t is just a series of numbers to plot the data against for now. Thank you in advance.
t=1:1:48;
dateFormat = 19;
datetick('x',dateFormat)
plot(t,Atlanta(:,8))
hold on
xlabel('Date')
ylabel('Percentage')
ylim([80 100])
plot(t,NY(:,4))
plot(t,Chicago)
legend('Atlanta','New York','Chicago')

 採用された回答

Star Strider
Star Strider 2020 年 11 月 7 日

0 投票

The datetick call needs to go after the plot call:
t=1:1:48;
plot(t,Atlanta(:,8))
hold on
dateFormat = 19;
datetick('x',dateFormat)
xlabel('Date')
ylabel('Percentage')
ylim([80 100])
plot(t,NY(:,4))
plot(t,Chicago)
legend('Atlanta','New York','Chicago')
Also, datetick requires datenum arguments for the x-axis values, so your current value of ‘t’ will not give recognisable results.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Dates and Time についてさらに検索

製品

リリース

R2020b

質問済み:

2020 年 11 月 7 日

回答済み:

2020 年 11 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by