How to set minor ticks for any particular position?

101 Ansichten (letzte 30 Tage)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA am 16 Mai 2022
Kommentiert: Voss am 17 Mai 2022
I need to set xticks from -4000 to 4000. I use the following command to set ticks at every 500.
xticks(-4000:500:4000)
But I need xticks at 100, 250, 750. How can set the ticks at those certain points?

Akzeptierte Antwort

Voss
Voss am 16 Mai 2022
To set minor ticks at 100, 250, 750 (as the title of the question implies):
figure();
xticks(-4000:500:4000);
set(gca(),'XMinorTick','on')
set(get(gca(),'XAxis'),'MinorTickValues',[100 250 750])
xlim([-1500 1500]) % to see the effect
Or, to set xticks at 100, 250, 750 and -4000:500:4000 (as the question itself asks):
figure();
xticks(sort([-4000:500:4000 100 250 750]))
xlim([-1500 1500]) % to see the effect
  2 Kommentare
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA am 17 Mai 2022
Bearbeitet: ANANTA BIJOY BHADRA am 17 Mai 2022
I can place them but they overlaps each other. Can I change the size of the of the values 100 250 750 so they does not overlap? I used the 2nd way.
Voss
Voss am 17 Mai 2022
You can try this:
xticks(sort([-4000:500:4000 100 250 750]))
xlim([-4000 4000]) % to see the effect
xtl = xticklabels();
idx = ismember(xtl,{'100' '250' '750'});
xtl(idx) = strcat('\fontsize{6}',xtl(idx));
xticklabels(xtl)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by