How to control Minortick number
20 views (last 30 days)
Show older comments
Hello,
Please how can i specify the number of minor ticks (X axis and y axis)?
thank you
0 Comments
Answers (1)
dpb
on 18 Feb 2018
Edited: dpb
on 18 Feb 2018
See the numeric ruler for some additional control over axis appearance not made visible by the axes object... <numeric ruler properties>
ADDENDUM
Had presumed would get the idea from the link since pointed it specifically at the MinorTickValues subsection. Given the follow-up comment, the "trick" would follow something like:
hAx=gca; % retrieve current axes handle
xt=hAx.XTick; % and the current tick values
nT=length(xt); % how many ticks are there???
nMinorT=2; % set how many minor tick divisions wanted
hAx.XAxis.MinorTickValues=linspace(xt(1),xt(end),(nT-1)*nMinorT+1) % set those values
hAx.XMinorTick='on' % and turn them on so show...
Obvious extension to Y,Z axes. Probably most handy if doing this more than just once will be to write a little utility function.
NB: nMinorT above is the number of divisions; the actual number of minor ticks is one less than the number of tick intervals. If want to actually set the count instead, just fix up the algebra to match in the linspace number expression--
hAx.XAxis.MinorTickValues=linspace(xt(1),xt(end),(nT-1)*(nMinorT+1)+1)
2 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!