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

1 visualización (últimos 30 días)
Afsher P A
Afsher P A el 27 de Jul. de 2020
Comentada: dpb el 30 de Jul. de 2020
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

Respuesta aceptada

dpb
dpb el 27 de Jul. de 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 comentarios
dpb
dpb el 30 de Jul. de 2020
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 el 30 de Jul. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by