How to label Y axes in place of column1 column 2 etc
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/337732/image.png)
How to label Y axes with month and year in place of column1 column2 etc
0 Kommentare
Akzeptierte Antwort
dpb
am 27 Jul. 2020
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 Kommentare
dpb
am 30 Jul. 2020
Works fine here...what specifically, is your code/data that doesn't work?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/339526/image.jpeg)
That's exactly what you asked for -- the labels as MMMYY instead of as "Column N"
What's more to want?
dpb
am 30 Jul. 2020
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!