gridmore.m

Version 2.1.0.0 (2.58 KB) by
Increases the number of grid lines where you want to, without adding more labels on the axis.

Updated 10 Mar 2017

% You create a graph and you do "grid on", but you want more of those major
% grid lines at certain values of the axis, without these values getting
% labeled: This function makes it happen. Especially interesting when data
% is not a continous but a discrete set (like "years"), so that the command
% "grid minor" is not appropriate. Tested in MATLAB2010b and MATLAB2016a.
% (I) USE AFTER "GRID ON"
% (II) s must be a string: 'x', 'y' or 'z' (the desired axis)

% Example 1:
% After creating a graph and doing "grid on", we want more lines
% at certain values of the x-axis. We save all the x-values we want
% with a grid line in a matrix "X". We do:

% >>gridmore(X,'x');

% Example 2:
% We are going to make different graphs and we want the same grid on
% the x-axis in all of them. We do, e.g., for the first figure:

% >>plot(A,B);
% grid on
% [xlabels]=gridmore(X,'x');

% For the following figures, don't call the function again; use the
% output argument "xlabels":

% >>plot(C,D);
% grid on
% set(gca,'Xtick',X,'XTickLabel',xlabels)

% How does gridmore.m work?
% XTick, YTick and ZTick are the location of the tick marks and major
% grid lines for each axis. XTickLabel, YTickLabel and ZtickLabel are the
% labels for each tick mark. The function increases the number of ticks
% labeling new ticks with an empty label.

% Any bugs, inquiries or suggestions to the comment section. Please rate.

% Thank you!

% Enjoy

% Exchange contributions

% gridmore.m (c) 2017, by Álvaro López de Quadros

% You should have received a copy of the license along with this
% work.

Cite As

Álvaro F. López de Quadros (2023). gridmore.m (https://www.mathworks.com/matlabcentral/fileexchange/61780-gridmore-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Grid Lines, Tick Values, and Labels in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
2.1.0.0