Editing tick marks figure

10 visualizaciones (últimos 30 días)
Floris Zoutman
Floris Zoutman el 17 de Sept. de 2012
Comentada: Voss el 2 de En. de 2024
I'm trying to add extra tick marks to my figure for percentiles of my sample, but I got a little stuck on how to do it. My current tick marks are coded like this: xt=(0:30000:150000)'; xtl=sprintf('%d |',xt'); set(gca,'xtick',xt) set(gca,'xticklabel',xtl);
Now I would like to add three more tickmarks in (vector) variable PERC and label them respectively P25, P50 and P75. I think it should be easy to adapt xt: xt=[xt;PERC'] . However, I don't understand how to edit variable xtl. Can anybody help me out on how to do it?

Respuestas (1)

Voss
Voss el 2 de En. de 2024
xlim([0 200000])
xt=0:30000:150000;
xtl=compose('%d',xt);
PERC = [45000 100000 130000]; % say
xt=[xt PERC];
xtl=[xtl 'P25' 'P50' 'P75'];
[~,idx] = sort(xt);
xt = xt(idx);
xtl = xtl(idx);
set(gca,'xtick',xt,'xticklabel',xtl);
  1 comentario
Voss
Voss el 2 de En. de 2024
What I would've done in 2012:
xlim([0 200000])
xt=0:30000:150000;
xtl=strtrim(cellstr(num2str(xt(:)))).';
PERC = [45000 100000 130000]; % say
xt=[xt PERC];
xtl=[xtl 'P25' 'P50' 'P75'];
[~,idx] = sort(xt);
xt = xt(idx);
xtl = xtl(idx);
set(gca,'xtick',xt,'xticklabel',xtl);

Iniciar sesión para comentar.

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by