Time Series with month names

7 ビュー (過去 30 日間)
emily bristow
emily bristow 2020 年 12 月 3 日
回答済み: Mathieu NOE 2020 年 12 月 3 日
How do I create a time series for average bottom water dissolved oxygen concentrations, with the month names across the x axis?
The attached excel file is the cocentrations
  1 件のコメント
BN
BN 2020 年 12 月 3 日
Hello,
Here is a simple way, But I'm sure it isn't the best way to do this.
% cd 'location of your excel file'
table = readtable('Bottom Water Average DO Time Series.xlsx'); % read excel file
plot(table.AverageDO)
set(gca,'xtick',1:7,...
'xticklabel',{'Mar','Apr','May','Jun','Jul','Aug','Nov'});
xlabel('Months') ;
ylabel('AverageDO') ;
Cris LaPierre's answer is the best and perfect solution for doing this.

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

回答 (3 件)

Cris LaPierre
Cris LaPierre 2020 年 12 月 3 日
Import your months as categoricals.
Categories are organized alphabetically by default. Use reordercats to place them in order.
Then, plot with the months on the X axis, and the values on the Y.

Rishik Ramena
Rishik Ramena 2020 年 12 月 3 日
You can just convert the month names to datetime.
T = readtable('Bottom Water Average DO Time Series.xlsx');
plot(datetime(T.Month,"InputFormat","MMMM"),T.AverageDO);

Mathieu NOE
Mathieu NOE 2020 年 12 月 3 日
hello Emily
this is my suggestion , with two plot options
filename = "Bottom Water Average DO Time Series.xlsx";
C = readcell(filename);
[m,n] = size(C);
my_xtick_label = string(C(2:m,1)); % start at row index 2 to ignore header line
data = cell2mat(C(2:m,2)); % start at row index 2 to ignore header line
%% plot
figure(1), plot(data,'*-');grid
set(gca,'xtick',1:m-1,'xticklabel',my_xtick_label)
xlabel('Month');
ylabel('Bottom Water Average DO Time');
figure(2), bar(data);
set(gca,'xtick',1:m-1,'xticklabel',my_xtick_label)
xlabel('Month');
ylabel('Bottom Water Average DO Time');

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by