How to label Y axes in place of column1 column 2 etc

1 回表示 (過去 30 日間)
Afsher P A
Afsher P A 2020 年 7 月 27 日
コメント済み: dpb 2020 年 7 月 30 日
clear; close all; clc
X = [1 : 1 : 31]
Y = [9 10 11 10 12 15 16 12 10 11 12 13 12 14 12 10 11 13 14 12 13 15 16 11 17 15 18 14 16 13 NaN; 14 12 10 11 13 14 12 13 15 16 11 10 12 15 16 11 17 15 18 14 16 10 12 15 16 12 10 11 15 16 12; 15 16 11 10 12 15 16 11 16 18 15 20 16 20 24 23 22 23 19 20 22 21 26 25 24 22 27 23 22 21 NaN; 23 19 20 22 21 26 25 24 22 15 16 12 10 11 12 13 15 16 11 16 18 15 20 16 20 24 22 21 26 25 24; 16 18 15 20 16 20 24 22 21 26 16 11 16 18 15 20 16 20 24 11 16 18 15 20 16 20 24 22 16 10 12; 10 12 15 16 12 13 14 12 13 15 16 11 10 18 15 20 16 20 24 11 16 18 15 18 15 20 16 20 24 22 NaN; 15 16 11 10 12 15 16 11 16 18 22 23 19 20 22 21 26 25 24 16 18 15 20 16 20 24 22 21 26 16 11; 20 24 23 22 23 19 20 22 21 26 15 16 11 10 12 15 16 11 16 18 10 12 15 16 12 13 14 12 13 15 NaN; 24 23 22 23 19 20 22 21 26 25 24 19 20 22 21 26 25 24 16 18 15 20 10 12 15 16 11 16 18 24 25; 26 25 24 19 20 22 21 26 25 24 22 15 16 12 10 23 22 23 19 20 22 21 26 25 24 23 22 23 19 20 22; 20 22 21 26 25 24 16 18 20 24 23 22 23 19 20 22 26 25 24 19 20 22 21 26 19 20 22 21 26 NaN NaN; 20 24 23 22 23 19 20 22 21 15 16 11 10 12 15 16 16 18 22 23 19 20 22 21 10 12 15 16 12 13 14]
Z = transpose(Y)
stackedplot (X,Z)
How to label Y axes with month and year in place of column1 column2 etc

採用された回答

dpb
dpb 2020 年 7 月 27 日
YT=cellstr(datetime(2020,1:12,1,'Format','MMMyy')); % cellstr array of MMMyy
hSP=stackedplot(YT.','DisplayLabels',YT); % stacked plot using y label strings
  3 件のコメント
dpb
dpb 2020 年 7 月 30 日
Works fine here...what specifically, is your code/data that doesn't work?
That's exactly what you asked for -- the labels as MMMYY instead of as "Column N"
What's more to want?
dpb
dpb 2020 年 7 月 30 日
I do see that stackedplot doesn't allow one to use ylabel, though. TMW seems to have locked it down pretty tight as for what one can/can't do...in first blush couldn't get at the underlying axes handles and the real kicker is can't use hold in order to put another axis on top. I hadn't tried text but suspect it'll not manage either for that part as there's no set of x,y coordinates to get to.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by