How can I specify the spacing between minor tick marks and minor grid lines in my figures in MATLAB?
263 views (last 30 days)
Show older comments
MathWorks Support Team
on 21 Jun 2011
Edited: MathWorks Support Team
on 25 Jul 2016
I make a plot in MATLAB and then turn on minor grid lines as follows:
plot(1:10)
grid minor
The minor grid lines are based on the placing of the minor tick marks. MATLAB automatically calculates the spacing between the minor tick marks. I would like to be able to set these manually in the same manner I can set the placing of major tick marks.
Accepted Answer
MathWorks Support Team
on 25 Jul 2016
The ability to set the number of minor tick marks and the spacing between them is not available in MATLAB (R2015a)
If you are using R2015a, here is the workaround,
you may use the LINE function to create your own minor tick marks, for example with:
figure
% specify the minor grid vector
xg = [0:0.025:1];
% specify the Y-position and the height of minor grids
yg = [0 0.1];
xx = reshape([xg;xg;NaN(1,length(xg))],1,length(xg)*3)
yy = repmat([yg NaN],1,length(xg))
h_minorgrid = line(xx,yy,'Color','r')
axis([0 1 0 10])
If you are using R2015b, workaround as follows,
plot(1:10);
ax = gca;
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = 1:0.5:10;
grid on;
ax.XMinorGrid = 'on';
0 Comments
More Answers (0)
See Also
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!