How do I create 2 x-axis labels?

75 Ansichten (letzte 30 Tage)
Carla Gustafsson
Carla Gustafsson am 21 Mai 2020
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

Antworten (1)

Srivardhan Gadila
Srivardhan Gadila am 28 Mai 2020
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');

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by