Editing tick marks figure
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
Voss
am 2 Jan. 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 Kommentar
Voss
am 2 Jan. 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);
Siehe auch
Kategorien
Mehr zu Install Products finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

