Mercurial > hg > octave-nkf
annotate scripts/plot/axis.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | b124b83e5626 |
children | b0084095098e |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1994-2011 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
590 | 18 |
3368 | 19 ## -*- texinfo -*- |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
20 ## @deftypefn {Function File} {} axis () |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
21 ## @deftypefnx {Function File} {} axis ([@var{x}_lo, @var{x}_hi]) |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
22 ## @deftypefnx {Function File} {} axis ([@var{x}_lo, @var{x}_hi, @var{y}_lo, @var{y}_hi]) |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
23 ## @deftypefnx {Function File} {} axis ([@var{x}_lo, @var{x}_hi, @var{y}_lo, @var{y}_hi, @var{z}_lo, @var{z}_hi]) |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
24 ## @deftypefnx {Function File} {} axis (@var{option}) |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
25 ## @deftypefnx {Function File} {} axis (@dots{}, @var{option}) |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
26 ## @deftypefnx {Function File} {} axis (@var{h}, @dots{}) |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
27 ## @deftypefnx {Function File} {@var{limits} =} axis () |
3667 | 28 ## Set axis limits for plots. |
3426 | 29 ## |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 ## The argument @var{limits} should be a 2-, 4-, or 6-element vector. The |
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 ## first and second elements specify the lower and upper limits for the |
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
32 ## x-axis. The third and fourth specify the limits for the y-axis, and the |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
8953
diff
changeset
|
33 ## fifth and sixth specify the limits for the z-axis. |
3426 | 34 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
35 ## Without any arguments, @code{axis} turns autoscaling on. |
4945 | 36 ## |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10557
diff
changeset
|
37 ## With one output argument, @code{x = axis} returns the current axes. |
3667 | 38 ## |
3668 | 39 ## The vector argument specifying limits is optional, and additional |
40 ## string arguments may be used to specify various axis properties. For | |
3667 | 41 ## example, |
42 ## | |
43 ## @example | |
44 ## axis ([1, 2, 3, 4], "square"); | |
45 ## @end example | |
46 ## | |
47 ## @noindent | |
3668 | 48 ## forces a square aspect ratio, and |
49 ## | |
50 ## @example | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
51 ## axis ("tic", "labely"); |
3668 | 52 ## @end example |
53 ## | |
54 ## @noindent | |
55 ## turns tic marks on for all axes and tic mark labels on for the y-axis | |
56 ## only. | |
3667 | 57 ## |
58 ## @noindent | |
59 ## The following options control the aspect ratio of the axes. | |
60 ## | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
61 ## @table @asis |
3667 | 62 ## @item "square" |
63 ## Force a square aspect ratio. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
64 ## |
3667 | 65 ## @item "equal" |
66 ## Force x distance to equal y-distance. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
67 ## |
3667 | 68 ## @item "normal" |
69 ## Restore the balance. | |
70 ## @end table | |
71 ## | |
72 ## @noindent | |
73 ## The following options control the way axis limits are interpreted. | |
74 ## | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
75 ## @table @asis |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
76 ## @item "auto" |
3667 | 77 ## Set the specified axes to have nice limits around the data |
78 ## or all if no axes are specified. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
79 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
80 ## @item "manual" |
3667 | 81 ## Fix the current axes limits. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
82 ## |
3667 | 83 ## @item "tight" |
9277
be84e9654feb
Update axis.m documentation to reflect addition of "tight" option.
Rik <rdrider0-list@yahoo.com>
parents:
9209
diff
changeset
|
84 ## Fix axes to the limits of the data. |
3667 | 85 ## @end table |
86 ## | |
87 ## @noindent | |
88 ## The option @code{"image"} is equivalent to @code{"tight"} and | |
89 ## @code{"equal"}. | |
90 ## | |
91 ## @noindent | |
92 ## The following options affect the appearance of tic marks. | |
93 ## | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
94 ## @table @asis |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
95 ## @item "on" |
3667 | 96 ## Turn tic marks and labels on for all axes. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
97 ## |
3667 | 98 ## @item "off" |
99 ## Turn tic marks off for all axes. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
100 ## |
3667 | 101 ## @item "tic[xyz]" |
3668 | 102 ## Turn tic marks on for all axes, or turn them on for the |
103 ## specified axes and off for the remainder. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
104 ## |
3667 | 105 ## @item "label[xyz]" |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
106 ## Turn tic labels on for all axes, or turn them on for the |
3668 | 107 ## specified axes and off for the remainder. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
108 ## |
3667 | 109 ## @item "nolabel" |
110 ## Turn tic labels off for all axes. | |
111 ## @end table | |
112 ## Note, if there are no tic marks for an axis, there can be no labels. | |
113 ## | |
114 ## @noindent | |
115 ## The following options affect the direction of increasing values on | |
116 ## the axes. | |
117 ## | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
118 ## @table @asis |
3667 | 119 ## @item "ij" |
120 ## Reverse y-axis, so lower values are nearer the top. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
121 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
122 ## @item "xy" |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
123 ## Restore y-axis, so higher values are nearer the top. |
3667 | 124 ## @end table |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
125 ## |
7189 | 126 ## If an axes handle is passed as the first argument, then operate on |
127 ## this axes rather than the current axes. | |
3368 | 128 ## @end deftypefn |
590 | 129 |
2314 | 130 ## Author: jwe |
131 | |
7189 | 132 function varargout = axis (varargin) |
590 | 133 |
7215 | 134 [h, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); |
7216 | 135 |
7215 | 136 oldh = gca (); |
137 unwind_protect | |
138 axes (h); | |
7189 | 139 varargout = cell (max (nargin == 0, nargout), 1); |
140 if (isempty (varargout)) | |
7215 | 141 __axis__ (h, varargin{:}); |
7189 | 142 else |
7215 | 143 [varargout{:}] = __axis__ (h, varargin{:}); |
7189 | 144 endif |
7215 | 145 unwind_protect_cleanup |
146 axes (oldh); | |
147 end_unwind_protect | |
590 | 148 |
7189 | 149 endfunction |
150 | |
151 function curr_axis = __axis__ (ca, ax, varargin) | |
152 | |
153 if (nargin == 1) | |
4945 | 154 if (nargout == 0) |
6257 | 155 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); |
4945 | 156 else |
6257 | 157 xlim = get (ca, "xlim"); |
158 ylim = get (ca, "ylim"); | |
9427
7b74a7fd4761
axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents:
9357
diff
changeset
|
159 view = get (ca, "view"); |
7b74a7fd4761
axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents:
9357
diff
changeset
|
160 if (view(2) == 90) |
10549 | 161 curr_axis = [xlim, ylim]; |
9427
7b74a7fd4761
axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents:
9357
diff
changeset
|
162 else |
10549 | 163 zlim = get (ca, "zlim"); |
164 curr_axis = [xlim, ylim, zlim]; | |
9427
7b74a7fd4761
axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents:
9357
diff
changeset
|
165 endif |
4945 | 166 endif |
3667 | 167 |
5443 | 168 elseif (ischar (ax)) |
4340 | 169 len = length (ax); |
3667 | 170 |
171 ## 'matrix mode' to reverse the y-axis | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
172 if (strcmpi (ax, "ij")) |
6257 | 173 set (ca, "ydir", "reverse"); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
174 elseif (strcmpi (ax, "xy")) |
6257 | 175 set (ca, "ydir", "normal"); |
3667 | 176 |
177 ## aspect ratio | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
178 elseif (strcmpi (ax, "image")) |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
179 __axis__ (ca, "equal") |
7376 | 180 __do_tight_option__ (ca); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
181 elseif (strcmpi (ax, "square")) |
10532
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10226
diff
changeset
|
182 set (ca, "plotboxaspectratio", [1, 1, 1]); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
183 elseif (strcmp (ax, "equal")) |
11577 | 184 if (strcmp (get (get (ca, "parent"), "__graphics_toolkit__"), "gnuplot")) |
11001
2ab8cc6dcced
Special treatment activepositionproperty = outerposition for gnuplot.
Ben Abbott <bpabbott@mac.com>
parents:
10953
diff
changeset
|
185 ## FIXME - gnuplot applies the aspect ratio activepostionproperty. |
2ab8cc6dcced
Special treatment activepositionproperty = outerposition for gnuplot.
Ben Abbott <bpabbott@mac.com>
parents:
10953
diff
changeset
|
186 set (ca, "activepositionproperty", "position"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
187 ## The following line is a trick used to trigger the recalculation of |
11185
5b48695f3c13
Making 'axis equal' equivalent to 'daspect([1,1,1])'
Konstantinos Poulios <logari81@googlemail.com>
parents:
11183
diff
changeset
|
188 ## aspect related magnitudes even if the aspect ratio is the same |
5b48695f3c13
Making 'axis equal' equivalent to 'daspect([1,1,1])'
Konstantinos Poulios <logari81@googlemail.com>
parents:
11183
diff
changeset
|
189 ## (useful with the x11 gnuplot terminal after a window resize) |
5b48695f3c13
Making 'axis equal' equivalent to 'daspect([1,1,1])'
Konstantinos Poulios <logari81@googlemail.com>
parents:
11183
diff
changeset
|
190 set (ca, "dataaspectratiomode", "auto"); |
11001
2ab8cc6dcced
Special treatment activepositionproperty = outerposition for gnuplot.
Ben Abbott <bpabbott@mac.com>
parents:
10953
diff
changeset
|
191 endif |
11185
5b48695f3c13
Making 'axis equal' equivalent to 'daspect([1,1,1])'
Konstantinos Poulios <logari81@googlemail.com>
parents:
11183
diff
changeset
|
192 set (ca, "dataaspectratio", [1, 1, 1]) |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
193 elseif (strcmpi (ax, "normal")) |
10557
e86651d2fde5
axis.m: For 'axis normal' restore plotboxaspectratio.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
194 set (ca, "plotboxaspectratio", [1, 1, 1]) |
10226
2884758e265b
Replace dataaspectratio props with plotboxaspectratio props.
Ben Abbott <bpabbott@mac.com>
parents:
9427
diff
changeset
|
195 set (ca, "plotboxaspectratiomode", "auto"); |
3667 | 196 |
197 ## axis limits | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
198 elseif (len >= 4 && strcmpi (ax(1:4), "auto")) |
4340 | 199 if (len > 4) |
10549 | 200 if (any (ax == "x")) |
201 set (ca, "xlimmode", "auto"); | |
202 endif | |
203 if (any (ax == "y")) | |
204 set (ca, "ylimmode", "auto"); | |
205 endif | |
206 if (any (ax == "z")) | |
207 set (ca, "zlimmode", "auto"); | |
208 endif | |
3667 | 209 else |
10549 | 210 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); |
3667 | 211 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
212 elseif (strcmpi (ax, "manual")) |
3667 | 213 ## fixes the axis limits, like axis(axis) should; |
6257 | 214 set (ca, "xlimmode", "manual", "ylimmode", "manual", "zlimmode", "manual"); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
215 elseif (strcmpi (ax, "tight")) |
7376 | 216 ## sets the axis limits to the min and max of all data. |
217 __do_tight_option__ (ca); | |
3667 | 218 ## tic marks |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
219 elseif (strcmpi (ax, "on") || strcmpi (ax, "tic")) |
6257 | 220 set (ca, "xtickmode", "auto", "ytickmode", "auto", "ztickmode", "auto"); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
221 if (strcmpi (ax, "on")) |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
222 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto", |
10549 | 223 "zticklabelmode", "auto"); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
224 endif |
6765 | 225 set (ca, "visible", "on"); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
226 elseif (strcmpi (ax, "off")) |
6257 | 227 set (ca, "xtick", [], "ytick", [], "ztick", []); |
6765 | 228 set (ca, "visible", "off"); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
229 elseif (len > 3 && strcmpi (ax(1:3), "tic")) |
4340 | 230 if (any (ax == "x")) |
10549 | 231 set (ca, "xtickmode", "auto"); |
3667 | 232 else |
10549 | 233 set (ca, "xtick", []); |
3667 | 234 endif |
4340 | 235 if (any (ax == "y")) |
10549 | 236 set (ca, "ytickmode", "auto"); |
3667 | 237 else |
10549 | 238 set (ca, "ytick", []); |
3667 | 239 endif |
4340 | 240 if (any (ax == "z")) |
10549 | 241 set (ca, "ztickmode", "auto"); |
3667 | 242 else |
10549 | 243 set (ca, "ztick", []); |
3667 | 244 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
245 elseif (strcmpi (ax, "label")) |
6257 | 246 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto", |
10549 | 247 "zticklabelmode", "auto"); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
248 elseif (strcmpi (ax, "nolabel")) |
6257 | 249 set (ca, "xticklabel", "", "yticklabel", "", "zticklabel", ""); |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7994
diff
changeset
|
250 elseif (len > 5 && strcmpi (ax(1:5), "label")) |
4340 | 251 if (any (ax == "x")) |
10549 | 252 set (ca, "xticklabelmode", "auto"); |
3667 | 253 else |
10549 | 254 set (ca, "xticklabel", ""); |
3667 | 255 endif |
4340 | 256 if (any (ax == "y")) |
10549 | 257 set (ca, "yticklabelmode", "auto"); |
3667 | 258 else |
10549 | 259 set (ca, "yticklabel", ""); |
3667 | 260 endif |
4340 | 261 if (any (ax == "z")) |
10549 | 262 set (ca, "zticklabelmode", "auto"); |
3667 | 263 else |
10549 | 264 set (ca, "zticklabel", ""); |
3667 | 265 endif |
266 | |
267 else | |
4259 | 268 warning ("unknown axis option '%s'", ax); |
3667 | 269 endif |
270 | |
4030 | 271 elseif (isvector (ax)) |
590 | 272 |
273 len = length (ax); | |
274 | |
275 if (len != 2 && len != 4 && len != 6) | |
276 error ("axis: expecting vector with 2, 4, or 6 elements"); | |
277 endif | |
278 | |
5627 | 279 for i = 1:2:len |
280 if (ax(i) == ax(i+1)) | |
10549 | 281 error ("axis: limits(%d) cannot equal limits(%d)", i, i+1); |
5627 | 282 endif |
283 endfor | |
284 | |
590 | 285 if (len > 1) |
6257 | 286 set (ca, "xlim", [ax(1), ax(2)]); |
590 | 287 endif |
288 | |
289 if (len > 3) | |
6257 | 290 set (ca, "ylim", [ax(3), ax(4)]); |
590 | 291 endif |
292 | |
293 if (len > 5) | |
6257 | 294 set (ca, "zlim", [ax(5), ax(6)]); |
590 | 295 endif |
296 | |
297 else | |
595 | 298 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); |
590 | 299 endif |
300 | |
7376 | 301 if (! isempty (varargin)) |
7189 | 302 __axis__ (ca, varargin{:}); |
3667 | 303 endif |
6447 | 304 |
590 | 305 endfunction |
3667 | 306 |
7376 | 307 function lims = __get_tight_lims__ (ca, ax) |
308 | |
309 ## Get the limits for axis ("tight"). | |
310 ## AX should be one of "x", "y", or "z". | |
7994
8ccd9b0bf6bc
plot/axis.m (__get_tight_lims__): don't fail if data is not a vector
John W. Eaton <jwe@octave.org>
parents:
7376
diff
changeset
|
311 kids = findobj (ca, "-property", strcat (ax, "data")); |
11174
2114867f2a50
axis.m: Exclude hggroup {x,y,z}data properties when determing tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents:
11001
diff
changeset
|
312 ## Since contours set the cdata for the patches to the hggroup zdata property, exclude |
2114867f2a50
axis.m: Exclude hggroup {x,y,z}data properties when determing tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents:
11001
diff
changeset
|
313 ## hgroups when determining the tight limits. |
2114867f2a50
axis.m: Exclude hggroup {x,y,z}data properties when determing tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents:
11001
diff
changeset
|
314 hg_kids = findobj (ca, "-property", strcat (ax, "data"), "type", "hggroup"); |
2114867f2a50
axis.m: Exclude hggroup {x,y,z}data properties when determing tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents:
11001
diff
changeset
|
315 kids = setdiff (kids, hg_kids); |
7376 | 316 if (isempty (kids)) |
317 ## Return the current limits. | |
7994
8ccd9b0bf6bc
plot/axis.m (__get_tight_lims__): don't fail if data is not a vector
John W. Eaton <jwe@octave.org>
parents:
7376
diff
changeset
|
318 lims = get (ca, strcat (ax, "lim")); |
7376 | 319 else |
7994
8ccd9b0bf6bc
plot/axis.m (__get_tight_lims__): don't fail if data is not a vector
John W. Eaton <jwe@octave.org>
parents:
7376
diff
changeset
|
320 data = get (kids, strcat (ax, "data")); |
11201
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
321 scale = get (ca, strcat (ax, "scale")); |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
322 if (strcmp (scale, "log")) |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
323 data(data<=0) = NaN; |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
324 end |
7376 | 325 if (iscell (data)) |
9317
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
326 data = data (find (! cellfun (@isempty, data))); |
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
327 if (! isempty (data)) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
328 lims_min = min (cellfun (@min, cellfun (@min, data, 'uniformoutput', false)(:))); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
329 lims_max = max (cellfun (@max, cellfun (@max, data, 'uniformoutput', false)(:))); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
330 lims = [lims_min, lims_max]; |
9317
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
331 else |
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
332 lims = [0, 1]; |
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
333 endif |
7376 | 334 else |
7994
8ccd9b0bf6bc
plot/axis.m (__get_tight_lims__): don't fail if data is not a vector
John W. Eaton <jwe@octave.org>
parents:
7376
diff
changeset
|
335 lims = [min(data(:)), max(data(:))]; |
8610
85c9906abfd1
use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
336 endif |
85c9906abfd1
use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
337 endif |
9357
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
338 |
7376 | 339 endfunction |
340 | |
341 function __do_tight_option__ (ca) | |
342 | |
343 set (ca, | |
344 "xlim", __get_tight_lims__ (ca, "x"), | |
11183
ac6a199be45e
Leave zlim unchanged during 'axis tight' on 2D plots
Konstantinos Poulios <logari81@googlemail.com>
parents:
11174
diff
changeset
|
345 "ylim", __get_tight_lims__ (ca, "y")); |
ac6a199be45e
Leave zlim unchanged during 'axis tight' on 2D plots
Konstantinos Poulios <logari81@googlemail.com>
parents:
11174
diff
changeset
|
346 if __calc_dimensions__ (ca) > 2 |
ac6a199be45e
Leave zlim unchanged during 'axis tight' on 2D plots
Konstantinos Poulios <logari81@googlemail.com>
parents:
11174
diff
changeset
|
347 set (ca, "zlim", __get_tight_lims__ (ca, "z")); |
ac6a199be45e
Leave zlim unchanged during 'axis tight' on 2D plots
Konstantinos Poulios <logari81@googlemail.com>
parents:
11174
diff
changeset
|
348 endif |
7376 | 349 |
350 endfunction | |
351 | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
352 %!demo |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
353 %! t=0:0.01:2*pi; x=sin(t); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
354 %! |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
355 %! subplot(221); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
356 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
357 %! title("normal plot"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
358 %! |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
359 %! subplot(222); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
360 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
361 %! title("square plot"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
362 %! axis("square"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
363 %! |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
364 %! subplot(223); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
365 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
366 %! title("equal plot"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
367 %! axis("equal"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11577
diff
changeset
|
368 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
369 %! subplot(224); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
370 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
371 %! title("normal plot again"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
372 %! axis("normal"); |
7376 | 373 |
3667 | 374 %!demo |
375 %! t=0:0.01:2*pi; x=sin(t); | |
376 %! | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
377 %! subplot(121); |
6746 | 378 %! plot(t, x); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
379 %! title("ij plot"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
380 %! axis("ij"); |
3667 | 381 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
382 %! subplot(122); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
383 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
384 %! title("xy plot"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
385 %! axis("xy"); |
3667 | 386 |
387 %!demo | |
388 %! t=0:0.01:2*pi; x=sin(t); | |
389 %! | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
390 %! subplot(331); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
391 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
392 %! title("x tics and labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
393 %! axis("ticx"); |
3667 | 394 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
395 %! subplot(332); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
396 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
397 %! title("y tics and labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
398 %! axis("ticy"); |
3667 | 399 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
400 %! subplot(333); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
401 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
402 %! title("axis off"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
403 %! axis("off"); |
3667 | 404 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
405 %! subplot(334); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
406 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
407 %! title("x and y tics, x labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
408 %! axis("labelx","tic"); |
3667 | 409 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
410 %! subplot(335); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
411 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
412 %! title("x and y tics, y labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
413 %! axis("labely","tic"); |
3667 | 414 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
415 %! subplot(336); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
416 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
417 %! title("all tics but no labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
418 %! axis("nolabel","tic"); |
3667 | 419 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
420 %! subplot(337); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
421 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
422 %! title("x tics, no labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
423 %! axis("nolabel","ticx"); |
3667 | 424 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
425 %! subplot(338); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
426 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
427 %! title("y tics, no labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
428 %! axis("nolabel","ticy"); |
3667 | 429 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
430 %! subplot(339); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
431 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
432 %! title("all tics and labels"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
433 %! axis("on"); |
3667 | 434 |
435 %!demo | |
436 %! t=0:0.01:2*pi; x=sin(t); | |
437 %! | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
438 %! subplot(321); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
439 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
440 %! title("axes at [0 3 0 1]") |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
441 %! axis([0,3,0,1]); |
3667 | 442 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
443 %! subplot(322); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
444 %! plot(t, x); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
445 %! title("auto"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
446 %! axis("auto"); |
3667 | 447 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
448 %! subplot(323); |
3667 | 449 %! plot(t, x, ";sine [0:2pi];"); hold on; |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
450 %! plot(-3:3,-3:3, ";line (-3,-3)->(3,3);"); hold off; |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
451 %! title("manual"); |
3667 | 452 %! axis("manual"); |
453 %! | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
454 %! subplot(324); |
3667 | 455 %! plot(t, x, ";sine [0:2pi];"); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
456 %! title("axes at [0 3 0 1], then autox"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
457 %! axis([0,3,0,1]); axis("autox"); |
3667 | 458 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
459 %! subplot(325); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
460 %! plot(t, x, ";sine [0:2p];"); |
3667 | 461 %! axis([3,6,0,1]); axis("autoy"); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
462 %! title("axes at [3 6 0 1], then autoy"); |
3667 | 463 %! |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
464 %! subplot(326); |
9317
96abf8f7e5b6
axis.m: Fix bug for 'axis tight' with multiple lines, modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
9277
diff
changeset
|
465 %! plot(t, sin(t), t, -2*sin(t/2)) |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
466 %! axis("tight"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
467 %! title("tight"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
468 |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
469 %!demo |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
470 %! clf |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
471 %! axis image |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
472 %! x=0:0.1:10; |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
473 %! plot(x,sin(x)) |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
474 %! axis image |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
475 %! title("image") |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
476 |
9357
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
477 %!demo |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
478 %! clf |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
479 %! [x,y,z] = peaks(50); |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
480 %! x1 = max(x(:)); |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
481 %! pcolor(x-x1,y-x1/2,z) |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
482 %! hold on |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
483 %! [x,y,z] = sombrero; |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
484 %! s = x1/max(x(:)); |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
485 %! pcolor(s*x+x1,s*y+x1/2,5*z) |
95ec56601497
axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
9317
diff
changeset
|
486 %! axis tight |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
487 |
11201
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
488 %!demo |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
489 %! clf |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
490 %! x = -10:10; |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
491 %! plot (x, x, x, -x) |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
492 %! set (gca, "yscale", "log") |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
493 %! legend ({"x >= 1", "x <= 1"}, "location", "north") |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
494 %! title ("ylim = [1, 10]") |
6c8791cb35b1
__go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents:
11191
diff
changeset
|
495 |