How to name/number each line graph in Y axis, instead of the 1-9 numbers?
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to name the line graphs in y axis like this (in red).
Program as follows
for i=1:9
g=GG(:,i)+i;
plot(X,g)
hold on
end
end
댓글 수: 0
채택된 답변
Jos (10584)
2016년 5월 11일
use the function text
text(X, Y, STR)
will place the string STR at the location (X,Y) on the current axes.
댓글 수: 2
Jos (10584)
2016년 5월 12일
Two options,
1) change the tick labels
set(gca,'ylim',[0 10],'ytick',1:9,'yticklabel',arrayfun(@(k) sprintf('%-.1f',k),-0.8:0.2:0.8,'un',0))
2) change the y-values
추가 답변 (1개)
Steven Lord
2016년 5월 11일
I would set the DisplayName property of each line as I created it, then call legend with the 'show' option afterwards.
M = magic(5);
for k = 1:size(M, 2)
plot(M(:, k), 'DisplayName', num2str(k, 'M(:, %d)'))
hold on
end
legend show
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!