如何将Xminortick作为数值值?

20 views (last 30 days)
Soroush Asarzadeh
Soroush Asarzadeh on 26 Feb 2016
Edited: Walter Roberson on 27 Feb 2016
嗨,我想知道我的X轴的次要步骤。Xtickmode设置为自动,我知道xminortick = {on/off},但是我想计算小步骤大小的数值,例如:xtick(2)-xtick(1):例如:
XTick = [0:2:10]
MajorStep = XTick(2) - XTick(1);% 2-0=2
ifMajorStep(2) - MajorStep(1) > 1
set(gca,'XMinorGrid','on','XMinorTick','on')
end
% now I want to calculate the minor step size
% MinorStep = XMinorTick(2) - XMinorTick(1) this obviously is not going to work but I want the numerical answer of it
Can anybody help me please?
1 Comment
dpb
dpb on 26 Feb 2016
Don't think so...the minor ticks values are hidden in HG with no way to access them. I suppose one could save the figure as an image and find the pixels that are set and deduce it from that but is pretty tough.
The best think one could do would be to try to work out heuristically how many minor ticks there will be based on the major tick spacing; by default it starts with five, if you increase the spacing as you did above in the example there are 10; if decrease by spacing at 0.5 for major then there's only 2. (These are divisions between major divisions, not the intermediate ticks). But I don't think there's any way to retrieve what is done internally.
附录 Oh, in digging following up Kevin's response I see there is a recent enhancement...but must have R2015b or later to gain access to it.

Sign in to comment.

Answers (1)

Kevin Claytor
Kevin Claytor on 26 Feb 2016
用斧头=轴对象
ax.XAxis.MinorTickValues
2 Comments

Sign in to comment.

Community Treasure Hunt

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

开始狩猎!