How to control Minortick number

20 views (last 30 days)
Tareq Al-Ma'aiteh
Tareq Al-Ma'aiteh on 18 Feb 2018
Edited: dpb on 18 Feb 2018
Hello,
Please how can i specify the number of minor ticks (X axis and y axis)?
thank you

Answers (1)

dpb
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
Tareq Al-Ma'aiteh
Tareq Al-Ma'aiteh on 18 Feb 2018
i checked it many times no option to select number of minor ticks
dpb
dpb on 18 Feb 2018
Edited: dpb on 18 Feb 2018
True; you must compute the spacing that matches the desired number and set those values...submit enhancement request; it's a a reasonable thing to have. linspace should help here quite a bit.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!