How do I create 2 x-axis labels?
조회 수: 74 (최근 30일)
이전 댓글 표시
I have seen a plot created with 2 x-axis labels, how does one do this? I want one label below a certain x-axis value, and another above that value. Below is an example of the plot.
I wanted to use the imagesc function to generate the plot, but found that the axes were of different lengths - the y-axis only went up to 20. So I used the pcolor function to generate my plot. The code is below, if anyone could tell me how to create the 2 labels on each axis, I would be grateful
load ovariancancer;
C= cov(obs');
figure();
pcolor(C);
colorbar ('eastoutside');
shading interp;
hold on;
havecancer = strcmp(grp, 'Cancer');
cancerpatients = numel(havecancer);
no_cancerp = sum(havecancer);
plot( [no_cancerp, no_cancerp], [0, cancerpatients],'k','linewidth',2);
plot( [0,cancerpatients], [no_cancerp, no_cancerp],'k','linewidth',2);
hold off
답변 (1개)
Srivardhan Gadila
2020년 5월 28일
The following code might help you:
% yAxis label 1
t = text(-20,60,'Cancer','HorizontalAlignment','center','FontWeight','bold');
set(t,'Rotation',90);
% yAxis label 2
t = text(-20,180,'Control','HorizontalAlignment','center','FontWeight','bold');
set(t,'Rotation',90);
% xAxis label 1
t = text(60,-20,'Cancer','HorizontalAlignment','center','FontWeight','bold');
% xAxis label 2
t = text(180,-20,'Control','HorizontalAlignment','center','FontWeight','bold');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!