gridmore.m

Increases the number of grid lines where you want to, without adding more labels on the axis.
50.0 次下载
更新时间 2017/3/10

查看许可证

% 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

% gridmore.m is licensed under MathWorks' license of choice for File
% Exchange contributions

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

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

引用格式

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

MATLAB 版本兼容性
创建方式 R2010b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
2.1.0.0

Removed Creative Commons License as demanded by The MATLAB Administration.

2.0.0.0

Typos fixed and revised wording. Tested in MATLAB2010b and 2016a. New and simpler input argument s. Now the function includes the call to "set" so you do not need to call it afterwards. A better second example. "USE AFTER GRID ON" explicitly stated.

1.0.0.0