/usr/share/freemat/toolbox/graph/axis.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | % AXIS AXIS Setup Axis Behavior
%
% Usage
%
% Control the axis behavior. There are several versions of the
% axis command based on what you would like the axis command to
% do. The first versions set scalings for the current plot.
% The general syntax for its use is
%
% axis([xmin xmax ymin ymax zmin zmax cmin cmax])
%
% which sets the limits in the X, Y, Z and color axes. You can
% also set only the X, Y and Z axes:
%
% axis([xmin xmax ymin ymax zmin zmax])
%
% or only the X and Y axes:
%
% axis([xmin xmax ymin ymax])
%
% To retrieve the current axis limits, use the syntax
%
% x = axis
%
% where x is a 4-vector for 2D plots, and a 6-vector for
% 3D plots.
%
% There are a number of axis options supported by FreeMat.
% The first version sets the axis limits to be automatically
% selected by FreeMat for each dimension. This state is the
% default one for new axes created by FreeMat.
%
% axis auto
%
% The next option sets all of the axis limits to manual
% mode. This state turns off automatic scaling of the axis
% based on the children of the current axis object.
%
% axis manual
%
% The next option sets the axis limits to fit tightly around
% the data.
%
% axis tight
%
% The next option adjusts the axis limits and plotbox aspect
% ratio so that the axis fills the position rectangle.
%
% axis fill
%
% The next option puts the axis in matrix mode. This mode
% is equivalent to the standard mode, but with the vertical
% axis reversed. Thus, the origin of the coordinate system
% is at the top left corner of the plot. This mode makes
% plots of matrix elements look normal (i.e., an identity
% matrix goes from upper left to lower right).
%
% axis ij
%
% The next option puts the axis in normal mode, with the origin
% at the lower left corner.
%
% axis xy
%
% The next option sets the axis parameters (specifically the
% data aspect ratio) so that equal ticks on each axis represent
% equal length. In this mode, spheres look spherical insteal of
% ellipsoidal.
%
% axis equal
%
% The next option is the same as axis equal, but sets the
% plot box to fit tightly around the data (so no background shows
% through). It is the best option to use when displaying images.
%
% axis image
%
% The next option makes the axis box square.
%
% axis square
%
% The next option restores many of the normal characteristics of
% the axis. In particular, it undoes the effects of square
% image and equal modes.
%
% axis normal
%
% The next mode freezes axis properties so that 3D objects can
% be rotated properly.
%
% axis vis3d
%
% The next mode turns off all labels, tick marks and background.
%
% axis on
%
% The next mode turns on all labels, tick marks and background.
%
% axis off
%
% The next mode is similar to axis off, but also repacks the
% figure as tightly as possible. The result is a plot box that
% takes up the entire outerposition vector.
%
% axis maximal
%
% The axis command can also be applied to a particular axis
% (as opposed to the current axis as returned by gca) handle
%
% axis(M,...)
%
% Copyright (c) 2002-2006 Samit Basu
% Licensed under the GPL
function retvec = axis(varargin);
if (length(varargin) > 0)
if (ishandle(varargin{1},'axes'))
ax = varargin{1};
varargin(1) = [];
else
ax = gca;
end
else
ax = gca;
end
saveca = gca;
axes(ax);
if (length(varargin) == 0)
% no args, just return the limits
if (is2dview(ax))
retvec = [get(ax,'xlim'),get(ax,'ylim')];
else
retvec = [get(ax,'xlim'),get(ax,'ylim'),get(ax,'zlim')];
end
else
mode = varargin{1};
if (isnumeric(mode))
HandleNumericMode(ax,mode);
elseif (strncmp(mode,'auto',4))
HandleAutoMode(ax,mode);
elseif (strcmp(mode,'manual'))
HandleManualMode(ax);
elseif (strcmp(mode,'tight'))
HandleTightMode(ax);
elseif (strcmp(mode,'fill'))
HandleFillMode(ax);
elseif (strcmp(mode,'ij'))
HandleIJMode(ax);
elseif (strcmp(mode,'xy'))
HandleXYMode(ax);
elseif (strcmp(mode,'equal'))
HandleEqualMode(ax);
elseif (strcmp(mode,'image'))
HandleImageMode(ax);
elseif (strcmp(mode,'square'))
HandleSquareMode(ax);
elseif (strcmp(mode,'normal'))
HandleNormalMode(ax);
elseif (strcmp(mode,'vis3d'))
HandleVis3DMode(ax);
elseif (strcmp(mode,'off'))
HandleOffMode(ax);
elseif (strcmp(mode,'on'))
HandleOnMode(ax);
elseif (strcmp(mode,'maximal'))
HandleMaximalMode(ax);
else
error(['Unrecognized mode ' mode ' argument to axis command']);
end
end
axes(saveca);
% axis autoxz --> xlimmod->auto, zlimmode->auto, ylimmode->manual
% axis manual --> xyzlimmode->manual
% axis tight --> set tight limits
% axis fill --> set plot box aspect so that axis fills position
% axis ij --> xdir->normal, ydir->reverse
% axis xy --> xdir->normal, ydir->normal
% axis equal --> 3D plot, --> image,
% 2D plot, dar->111, ?
% axis image --> dar->111, pbar-->auto, tight
% axis square --> pbar->111, dar->auto
% axis normal --> pbar->auto, dar->auto
% axis vis3d --> darmode->manual, pbarmode->manual
% axis off --> visible off, title->visible on
% axis on --> visible on
function HandleFillMode(ax)
pos = get(ax,'position');
fsize = get(get(ax,'parent'),'figsize');
width = pos(3)*fsize(1); height = pos(3)*fsize(2);
set(ax,'plotboxaspectratio',[width,height,1]);
function HandleOnMode(ax)
set(ax,'visible','on');
function HandleOffMode(ax)
set(ax,'visible','off');
function HandleVis3DMode(ax)
set(ax,'plotboxaspectratiomode','manual','dataaspectratiomode','manual');
function HandleNormalMode(ax)
set(ax,'plotboxaspectratiomode','auto','dataaspectratiomode','auto');
function HandleSquareMode(ax)
set(ax,'plotboxaspectratio',[1,1,1],'dataaspectratiomode','auto');
function HandleImageMode(ax)
set(ax,'dataaspectratio',[1,1,1],'plotboxaspectratiomode','auto');
lims = get(ax,'datalimits');
set(ax,'xlim',lims(1:2),'ylim',lims(3:4),'zlim',lims(5:6));
set(ax,'ydir','reverse');
function HandleEqualMode(ax)
set(ax,'dataaspectratio',[1,1,1]);
function HandleXYMode(ax)
set(ax,'xdir','normal','ydir','normal');
function HandleIJMode(ax)
set(ax,'xdir','normal','ydir','reverse');
function HandleTightMode(ax)
lims = get(ax,'datalimits');
set(ax,'xlim',lims(1:2),'ylim',lims(3:4),'zlim',lims(5:6));
function HandleManualMode(ax)
set(ax,'xlimmode','manual','ylimmode','manual','zlimmode','manual');
function HandleMaximalMode(ax)
set(ax,'xtick',[],'ytick',[],'ztick',[],'xticklabel','','yticklabel','','zticklabel','');
function HandleAutoMode(ax,mode)
allactive = strcmp(mode,'auto');
xactive = any(find(mode == 'x'));
yactive = any(find(mode == 'y'));
zactive = any(find(mode == 'z'));
if (allactive | xactive), set(ax,'xlimmode','auto'), end
if (allactive | yactive), set(ax,'ylimmode','auto'), end
if (allactive | zactive), set(ax,'zlimmode','auto'), end
function HandleNumericMode(ax,mode)
mode = mode(:);
if (length(mode) == 2)
set(ax,'xlim',mode);
elseif (length(mode) == 4)
set(ax,'xlim',mode(1:2),'ylim',mode(3:4));
elseif (length(mode) == 6)
set(ax,'xlim',mode(1:2),'ylim',mode(3:4),'zlim',mode(5:6));
elseif (length(mode) == 8)
set(ax,'xlim',mode(1:2),'ylim',mode(3:4),'zlim',mode(5:6),'clim',mode(7:8));
else
error('Unrecognized mode in call to axis - expected 2,4,6 or 8 arguments');
end
|