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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by