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
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');

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by