How to set minor ticks for any particular position?
101 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Voss
2022-5-16
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 个评论
Voss
2022-5-17
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!