time | Calls | line |
|---|
| | 1 | function [ans1, ans2, ans3] = axis(varargin)
|
| | 2 | %AXIS Control axis scaling and appearance.
|
| | 3 | % AXIS([XMIN XMAX YMIN YMAX]) sets scaling for the x- and y-axes
|
| | 4 | % on the current plot.
|
| | 5 | % AXIS([XMIN XMAX YMIN YMAX ZMIN ZMAX]) sets the scaling for the
|
| | 6 | % x-, y- and z-axes on the current 3-D plot.
|
| | 7 | % AXIS([XMIN XMAX YMIN YMAX ZMIN ZMAX CMIN CMAX]) sets the
|
| | 8 | % scaling for the x-, y-, z-axes and color scaling limits on
|
| | 9 | % the current axis (see CAXIS).
|
| | 10 | % V = AXIS returns a row vector containing the scaling for the
|
| | 11 | % current plot. If the current view is 2-D, V has four
|
| | 12 | % components; if it is 3-D, V has six components.
|
| | 13 | %
|
| | 14 | % AXIS AUTO returns the axis scaling to its default, automatic
|
| | 15 | % mode where, for each dimension, 'nice' limits are chosen based
|
| | 16 | % on the extents of all line, surface, patch, and image children.
|
| | 17 | % AXIS MANUAL freezes the scaling at the current limits, so that if
|
| | 18 | % HOLD is turned on, subsequent plots will use the same limits.
|
| | 19 | % AXIS TIGHT sets the axis limits to the range of the data.
|
| | 20 | % AXIS FILL sets the axis limits and PlotBoxAspectRatio so that
|
| | 21 | % the axis fills the position rectangle. This option only has
|
| | 22 | % an effect if PlotBoxAspectRatioMode or DataAspectRatioMode are
|
| | 23 | % manual.
|
| | 24 | %
|
| | 25 | % AXIS IJ puts MATLAB into its "matrix" axes mode. The coordinate
|
| | 26 | % system origin is at the upper left corner. The i axis is
|
| | 27 | % vertical and is numbered from top to bottom. The j axis is
|
| | 28 | % horizontal and is numbered from left to right.
|
| | 29 | % AXIS XY puts MATLAB into its default "Cartesian" axes mode. The
|
| | 30 | % coordinate system origin is at the lower left corner. The x
|
| | 31 | % axis is horizontal and is numbered from left to right. The y
|
| | 32 | % axis is vertical and is numbered from bottom to top.
|
| | 33 | %
|
| | 34 | % AXIS EQUAL sets the aspect ratio so that equal tick mark
|
| | 35 | % increments on the x-,y- and z-axis are equal in size. This
|
| | 36 | % makes SPHERE(25) look like a sphere, instead of an ellipsoid.
|
| | 37 | % AXIS IMAGE is the same as AXIS EQUAL except that the plot
|
| | 38 | % box fits tightly around the data.
|
| | 39 | % AXIS SQUARE makes the current axis box square in size.
|
| | 40 | % AXIS NORMAL restores the current axis box to full size and
|
| | 41 | % removes any restrictions on the scaling of the units.
|
| | 42 | % This undoes the effects of AXIS SQUARE and AXIS EQUAL.
|
| | 43 | % AXIS VIS3D freezes aspect ratio properties to enable rotation of
|
| | 44 | % 3-D objects and overrides stretch-to-fill.
|
| | 45 | %
|
| | 46 | % AXIS OFF turns off all axis labeling, tick marks and background.
|
| | 47 | % AXIS ON turns axis labeling, tick marks and background back on.
|
| | 48 | %
|
| | 49 | % AXIS(H,...) changes the axes handles listed in vector H.
|
| | 50 | %
|
| | 51 | % See also AXES, GRID, SUBPLOT, XLIM, YLIM, ZLIM, RLIM
|
| | 52 |
|
| | 53 | % Copyright 1984-2020 The MathWorks, Inc.
|
| | 54 |
|
< 0.001 | 1 | 55 | if nargin > 0
|
< 0.001 | 1 | 56 | [varargin{:}] = convertStringsToChars(varargin{:});
|
< 0.001 | 1 | 57 | end
|
| | 58 |
|
| | 59 | % Get the list of axes to operate upon
|
< 0.001 | 1 | 60 | if ~isempty(varargin) && allAxes(varargin{1})
|
| | 61 | ax = varargin{1}(:);
|
| | 62 | ax = handle(ax);
|
| | 63 | varargin=varargin(2:end);
|
< 0.001 | 1 | 64 | else
|
< 0.001 | 1 | 65 | ax = gca;
|
< 0.001 | 1 | 66 | if ~isa(ax,'matlab.graphics.axis.AbstractAxes') ||...
|
| 1 | 67 | isa(ax,'matlab.graphics.axis.GeographicAxes')
|
| | 68 | error(message('MATLAB:Chart:UnsupportedConvenienceFunction', 'axis', ax.Type));
|
< 0.001 | 1 | 69 | end
|
< 0.001 | 1 | 70 | end
|
| | 71 |
|
< 0.001 | 1 | 72 | ans1set = false;
|
< 0.001 | 1 | 73 | pbarlimit = 0.1;
|
| | 74 |
|
| | 75 | %---Check for bypass option (only supported for single axes)
|
< 0.001 | 1 | 76 | if length(ax)==1 && isappdata(ax,'MWBYPASS_axis')
|
| | 77 | if isempty(varargin)
|
| | 78 | ans1 = mwbypass(ax,'MWBYPASS_axis');
|
| | 79 | ans1set = true;
|
| | 80 | else
|
| | 81 | mwbypass(ax,'MWBYPASS_axis',varargin{:});
|
| | 82 | end
|
< 0.001 | 1 | 83 | elseif isempty(varargin)
|
| | 84 | if length(ax)==1
|
| | 85 | error(LocCheckCompatibleLimits(ax));
|
| | 86 | ans1=LocGetLimits(ax);
|
| | 87 | ans1set = true;
|
| | 88 | else
|
| | 89 | ans1=cell(length(ax),1);
|
| | 90 | ans1set = true;
|
| | 91 | for i=1:length(ax)
|
| | 92 | error(LocCheckCompatibleLimits(ax(i)));
|
| | 93 | ans1{i}=LocGetLimits(ax(i));
|
| | 94 | end
|
| | 95 | end
|
< 0.001 | 1 | 96 | else
|
< 0.001 | 1 | 97 | for j=1:length(ax)
|
< 0.001 | 1 | 98 | matlab.graphics.internal.markFigure(ax(j));
|
< 0.001 | 1 | 99 | for i = 1:length(varargin)
|
< 0.001 | 1 | 100 | cur_arg = varargin{i};
|
< 0.001 | 1 | 101 | names = get(ax(j),'DimensionNames');
|
| | 102 |
|
| | 103 | % Set limits manually with 4/6/8 element vector
|
< 0.001 | 1 | 104 | if ~ischar(cur_arg)
|
| | 105 | if any(isgraphics(cur_arg)) && ~isnumeric(cur_arg)
|
| | 106 | for k = 1:numel(cur_arg)
|
| | 107 | if ~isa(cur_arg(k), 'matlab.graphics.axis.Axes')
|
| | 108 | error(message('MATLAB:axis:NonAxisGraphicsHandle'));
|
| | 109 | end
|
| | 110 | end
|
| | 111 | end
|
| | 112 | error(LocCheckCompatibleLimits(ax(j)));
|
| | 113 | LocSetLimits(ax(j),cur_arg,names);
|
| | 114 |
|
| | 115 | % handle AUTO, AUTO[XYZ]:
|
< 0.001 | 1 | 116 | elseif strcmp(cur_arg(1:min(4,length(cur_arg))),'auto')
|
| | 117 | LocSetAuto(ax(j),cur_arg,names);
|
| | 118 |
|
| | 119 | % handle TIGHT
|
< 0.001 | 1 | 120 | elseif(strcmp(cur_arg,'tight'))
|
| | 121 | LocSetLimitMethod(ax(j),names,'tight');
|
| | 122 |
|
| | 123 | % handle PADDED
|
< 0.001 | 1 | 124 | elseif(strcmp(cur_arg,'padded'))
|
| | 125 | LocSetLimitMethod(ax(j),names,'padded');
|
| | 126 |
|
< 0.001 | 1 | 127 | elseif(strcmp(cur_arg,'tickaligned'))
|
| | 128 | LocSetLimitMethod(ax(j),names,'tickaligned');
|
| | 129 |
|
| | 130 | % handle FILL:
|
< 0.001 | 1 | 131 | elseif(strcmp(cur_arg, 'fill'))
|
| | 132 | if ~iscartesian(ax(j))
|
| | 133 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 134 | end
|
| | 135 | if ~isnumericAxes(ax(j))
|
| | 136 | error(message('MATLAB:axis:NumericAxes', cur_arg));
|
| | 137 | end
|
| | 138 | LocSetFill(ax(j),pbarlimit);
|
| | 139 |
|
| | 140 | % handle MANUAL:
|
< 0.001 | 1 | 141 | elseif(strcmp(cur_arg, 'manual'))
|
| | 142 | LocSetManual(ax(j),names);
|
| | 143 |
|
| | 144 | % handle IJ:
|
< 0.001 | 1 | 145 | elseif(strcmp(cur_arg, 'ij'))
|
| | 146 | if ~iscartesian(ax(j))
|
| | 147 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 148 | end
|
| | 149 | set(ax(j),...
|
| | 150 | 'XDir','normal',...
|
| | 151 | 'YDir','reverse');
|
| | 152 |
|
| | 153 | % handle XY:
|
< 0.001 | 1 | 154 | elseif(strcmp(cur_arg, 'xy'))
|
| | 155 | if ~iscartesian(ax(j))
|
| | 156 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 157 | end
|
| | 158 | set(ax(j),...
|
| | 159 | 'XDir','normal',...
|
| | 160 | 'YDir','normal');
|
| | 161 |
|
| | 162 | % handle SQUARE:
|
< 0.001 | 1 | 163 | elseif(strcmp(cur_arg, 'square'))
|
| | 164 | if ~iscartesian(ax(j))
|
| | 165 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 166 | end
|
| | 167 | set(ax(j),...
|
| | 168 | 'PlotBoxAspectRatio',[1 1 1],...
|
| | 169 | 'DataAspectRatioMode','auto')
|
| | 170 |
|
| | 171 | % handle EQUAL:
|
< 0.001 | 1 | 172 | elseif(strcmp(cur_arg, 'equal'))
|
< 0.001 | 1 | 173 | if ~iscartesian(ax(j))
|
| | 174 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
< 0.001 | 1 | 175 | end
|
0.005 | 1 | 176 | if ~isnumericAxes(ax(j))
|
| | 177 | error(message('MATLAB:axis:NumericAxes', cur_arg));
|
< 0.001 | 1 | 178 | end
|
0.015 | 1 | 179 | LocSetEqual(ax(j),pbarlimit);
|
| | 180 |
|
| | 181 | % handle IMAGE:
|
| | 182 | elseif(strcmp(cur_arg,'image'))
|
| | 183 | if ~iscartesian(ax(j))
|
| | 184 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 185 | end
|
| | 186 | if ~isnumericAxes(ax(j))
|
| | 187 | error(message('MATLAB:axis:NumericAxes', cur_arg));
|
| | 188 | end
|
| | 189 | LocSetImage(ax(j),pbarlimit);
|
| | 190 |
|
| | 191 | % handle NORMAL:
|
| | 192 | elseif(strcmp(cur_arg, 'normal'))
|
| | 193 | hax = handle(ax(j));
|
| | 194 | if isprop(hax,'PlotBoxAspectRatioMode')
|
| | 195 | set(ax(j),'PlotBoxAspectRatioMode','auto');
|
| | 196 | end
|
| | 197 | if isprop(hax,'DataAspectRatioMode')
|
| | 198 | set(ax(j),'DataAspectRatioMode','auto');
|
| | 199 | end
|
| | 200 | if isprop(hax,'CameraViewAngleMode')
|
| | 201 | set(ax(j),'CameraViewAngleMode','auto');
|
| | 202 | end
|
| | 203 |
|
| | 204 | % handle OFF:
|
| | 205 | elseif(strcmp(cur_arg, 'off'))
|
| | 206 | set(ax(j),'Visible','off');
|
| | 207 | set(get(ax(j),'Title'),'Visible','on');
|
| | 208 |
|
| | 209 | % handle ON:
|
| | 210 | elseif(strcmp(cur_arg, 'on'))
|
| | 211 | set(ax(j),'Visible','on');
|
| | 212 |
|
| | 213 | % handle VIS3D:
|
| | 214 | elseif(strcmp(cur_arg,'vis3d'))
|
| | 215 | if ~iscartesian(ax(j))
|
| | 216 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 217 | end
|
| | 218 | set(ax(j),'CameraViewAngle',get(ax(j),'CameraViewAngle'));
|
| | 219 | set(ax(j),'PlotBoxAspectRatio',get(ax(j),'PlotBoxAspectRatio'));
|
| | 220 | set(ax(j),'DataAspectRatio',get(ax(j),'DataAspectRatio'));
|
| | 221 |
|
| | 222 | % handle STATE:
|
| | 223 | elseif(strcmp(cur_arg, 'state'))
|
| | 224 | if ~iscartesian(ax(j))
|
| | 225 | error(message('MATLAB:axis:CartesianAxes', cur_arg));
|
| | 226 | end
|
| | 227 | warning('MATLAB:graph2d:axis:ObsoleteState', '%s', getString(message('MATLAB:axis:ObsoleteState')));
|
| | 228 | %note that this will keep overwriting arg1 etc if there is more
|
| | 229 | %than one axes in the list
|
| | 230 | [ans1,ans2,ans3]=LocGetState(ax(1));
|
| | 231 | ans1set = true;
|
| | 232 |
|
| | 233 | %if nargout>1
|
| | 234 | % ans2=ans2q;
|
| | 235 | % if nargout>2
|
| | 236 | % ans3=ans3q;
|
| | 237 | % end
|
| | 238 | %end
|
| | 239 |
|
| | 240 | % handle ERROR (NONE OF THE ABOVE STRINGS FOUND):
|
| | 241 | else
|
| | 242 | error(message('MATLAB:axis:UnknownOption', cur_arg));
|
< 0.001 | 1 | 243 | end
|
< 0.001 | 1 | 244 | end
|
< 0.001 | 1 | 245 | end
|
< 0.001 | 1 | 246 | end
|
| | 247 |
|
< 0.001 | 1 | 248 | if nargout > 0 && ~ans1set
|
| | 249 | nargoutchk(0, 0);
|
< 0.001 | 1 | 250 | end
|
Other subfunctions in this file are not included in this listing.