You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
This package contains 3 functions: xaxis, yaxis, and zaxis. The goal is to make common plot changes quicker and more convenient to apply.
You can interact with these functions similar to the way the axis command is used, except commands are applied only to the single axis being called. The documentation for the xaxis function is below; documentation for the other two functions are identical (save for the axis title).
%XAXIS controlls the plot like AXIS does, but just for the x-axis
% XAXIS([MIN MAX]) sets scaling for the axes on the current plot.
% use a NaN value to exclude scaling of that specific limit;
% for instance, XAXIS([NaN, MAX]) only sets the max value
% V = XAXIS returns a row vector containing the scaling for the
% current dimension of the current plot.
%
% XAXIS AUTO returns the axis scaling to its default, automatic
% mode where, for each dimension, 'nice' limits are chosen based
% on the extents of all line, surface, patch, and image children.
% XAXIS TIGHT sets the axis limits to the range of the data.
% XAXIS ROUND# rounds the max/min values to upward/downward to the
% nearest number of significant figures, as specified by #.
% If no # value is provided, it defaults to 1 sig fig.
% e.g., XAXIS ROUND2 will round the tight-axis bounds outwards to the
% nearest two significant figures
%
% XAXIS REVERSE reverses the axes
% XAXIS LOG sets the axis to log scaling
% XAXIS NORMAL restores settings back to default shape/scale
% This undoes the effects of XAXIS REVERSE and XAXIS LOG
%
Together, these functions can simplify a lot of plot cleanup. For example, if I want to format my plot such that:
- the x-axis is tightly set around the limits of my data
- the minimum y-axis value is set to zero
- the maximum y-axis value is kept at the default
then we need only use the following commands:
xaxis tight,
yaxis([0, NaN])
Without using these functions, accomplishing the same thing takes quite a bit more effort, and would look something like this:
lims_loose = axis();
axis tight
lims_tight = axis();
axis([lims_tight(1:2), 0, lims_loose(4)])
Cite As
Derek Wood (2026). Separate Plot Axis Commands (https://ch.mathworks.com/matlabcentral/fileexchange/184330-separate-plot-axis-commands), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0 (7.19 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0 |
