How to set minor ticks for any particular position?

107 visualizaciones (últimos 30 días)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA el 16 de Mayo de 2022
Comentada: Voss el 17 de Mayo de 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?

Respuesta aceptada

Voss
Voss el 16 de Mayo de 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 comentarios
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA el 17 de Mayo de 2022
Editada: ANANTA BIJOY BHADRA el 17 de Mayo de 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 el 17 de Mayo de 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)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by