How do I create 2 x-axis labels?

71 vues (au cours des 30 derniers jours)
Carla Gustafsson
Carla Gustafsson le 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
  1 commentaire
darova
darova le 21 Mai 2020
Use annotation or text

Connectez-vous pour commenter.

Réponses (1)

Srivardhan Gadila
Srivardhan Gadila le 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');

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by