How to set minor ticks for any particular position?
101 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Voss
on 16 May 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 Comments
Voss
on 17 May 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)
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!