Set string labels for a plot with multiple lines
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I create a plot with 3 lines with xTickLabels set as follows:
A=[1 2 3 8]; B=[2 4 5 6];
C=[5 7 11 12];
xaxis = [1:4];
semilogy(xaxis,A,'o-',xaxis,B,'o-',xaxis,C,'o-')
xlabel={'sample1','sample2','sample3','sample4'};
set(gca,'xticklabel',xlabel)
I want to mark the 4 points on the xaxis with the strings sample1,sample2,sample3 and sample4.
The above code is not quite doing that. Any suggestions on how to fix this?
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2016년 4월 19일
편집: Azzi Abdelmalek
2016년 4월 19일
A=[1 2 3 8]; B=[2 4 5 6];
C=[5 7 11 12];
xaxis = [1:4];
semilogy(xaxis,A,'o-',xaxis,B,'o-',xaxis,C,'o-')
xlabel1={'sample1','sample2','sample3','sample4'};
xt=xlim
set(gca,'xtick',linspace(xt(1),xt(2),4))
set(gca,'xticklabel',xlabel1)
댓글 수: 2
Azzi Abdelmalek
2016년 4월 19일
To generate xlabel1, you can use
xlabel1=genvarname(repmat({'sample'},1,4),'sample')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!