annotate scripts/plot/axis.m @ 17564:234731d524c2

axis.m: Fix 'axis tight' with pcolor plots. * libinterp/corefcn/graphics.cc(calc_dimensions): Use if/else if tree to avoid unnecessary comparisons once object has been determined to be 3-D. * libinterp/corefcn/graphics.cc(F__calc_dimensions__): Put input validation first. * scripts/plot/axis.m: Check for 2D view (elevation = 90) before setting Z limits.
author Rik <rik@octave.org>
date Fri, 04 Oct 2013 06:59:31 -0700
parents 15d592c82abc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14092
diff changeset
1 ## Copyright (C) 1994-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6765
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6765
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6765
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6765
diff changeset
17 ## <http://www.gnu.org/licenses/>.
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3106
diff changeset
19 ## -*- texinfo -*-
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10557
diff changeset
20 ## @deftypefn {Function File} {} axis ()
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11589
diff changeset
21 ## @deftypefnx {Function File} {} axis ([@var{x}_lo @var{x}_hi])
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11589
diff changeset
22 ## @deftypefnx {Function File} {} axis ([@var{x}_lo @var{x}_hi @var{y}_lo @var{y}_hi])
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11589
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])
10687
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})
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
26 ## @deftypefnx {Function File} {} axis (@var{hax}, @dots{})
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10687
diff changeset
27 ## @deftypefnx {Function File} {@var{limits} =} axis ()
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
28 ## Set axis limits and appearance.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3368
diff changeset
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
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3368
diff changeset
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
4bd917f8a4a7 [project @ 2004-08-31 15:09:17 by jwe]
jwe
parents: 4340
diff changeset
36 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
37 ## With one output argument, @code{@var{limits} = axis} returns the current
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
38 ## axis limits.
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
39 ##
3668
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
40 ## The vector argument specifying limits is optional, and additional
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
41 ## string arguments may be used to specify various axis properties. For
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
42 ## example,
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
43 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
44 ## @example
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
45 ## axis ([1, 2, 3, 4], "square");
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
46 ## @end example
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
47 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
48 ## @noindent
3668
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
49 ## forces a square aspect ratio, and
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
50 ##
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
51 ## @example
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52 ## axis ("tic", "labely");
3668
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
53 ## @end example
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
54 ##
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
55 ## @noindent
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
56 ## turns tic marks on for all axes and tic mark labels on for the y-axis
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
57 ## only.
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
58 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
59 ## @noindent
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
60 ## The following options control the aspect ratio of the axes.
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
61 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
62 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
63 ## @item @qcode{"square"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
64 ## Force a square aspect ratio.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
65 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
66 ## @item @qcode{"equal"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
67 ## Force x distance to equal y-distance.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
68 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
69 ## @item @qcode{"normal"}
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
70 ## Restore default aspect ratio.
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
71 ## @end table
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
72 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
73 ## @noindent
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
74 ## The following options control the way axis limits are interpreted.
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
75 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
76 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
77 ## @item @qcode{"auto"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
78 ## Set the specified axes to have nice limits around the data
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
79 ## or all if no axes are specified.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
80 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
81 ## @item @qcode{"manual"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
82 ## Fix the current axes limits.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
83 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
84 ## @item @qcode{"tight"}
9277
be84e9654feb Update axis.m documentation to reflect addition of "tight" option.
Rik <rdrider0-list@yahoo.com>
parents: 9209
diff changeset
85 ## Fix axes to the limits of the data.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
86 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
87 ## @item @qcode{"image"}
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
88 ## Equivalent to @qcode{"tight"} and @qcode{"equal"}.
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
89 ## @end table
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
90 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
91 ## @noindent
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
92 ## The following options affect the appearance of tic marks.
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
93 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
94 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
95 ## @item @qcode{"on"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
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 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
98 ## @item @qcode{"off"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
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 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
101 ## @item @qcode{"tic[xyz]"}
3668
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
102 ## Turn tic marks on for all axes, or turn them on for the
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
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 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
105 ## @item @qcode{"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
b0a68efa1295 [project @ 2000-05-13 06:40:56 by jwe]
jwe
parents: 3667
diff changeset
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 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
109 ## @item @qcode{"nolabel"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
110 ## Turn tic labels off for all axes.
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
111 ## @end table
15007
8f0e3c5bfa5f doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents: 14868
diff changeset
112 ##
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
113 ## Note, if there are no tic marks for an axis, there can be no labels.
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
114 ##
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
115 ## @noindent
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
116 ## The following options affect the direction of increasing values on the axes.
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
117 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
118 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
119 ## @item @qcode{"ij"}
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
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 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17211
diff changeset
122 ## @item @qcode{"xy"}
11587
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
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
124 ## @end table
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11577
diff changeset
125 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
126 ## If the first argument @var{hax} is an axes handle, then operate on
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
127 ## this axes rather than the current axes returned by @code{gca}.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
128 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17045
diff changeset
129 ## @seealso{xlim, ylim, zlim, daspect, pbaspect, box, grid}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3106
diff changeset
130 ## @end deftypefn
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
131
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
132 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
133
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
134 function limits = axis (varargin)
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
135
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
136 [hax, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:});
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
137
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17190
diff changeset
138 oldfig = [];
17301
68bcac3c043a Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents: 17281
diff changeset
139 if (! isempty (hax))
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17190
diff changeset
140 oldfig = get (0, "currentfigure");
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17190
diff changeset
141 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
142 unwind_protect
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
143 if (isempty (hax))
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
144 hax = gca ();
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
145 endif
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
146 if (nargin == 0)
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
147 limits = __axis__ (hax, varargin{:});
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
148 else
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
149 __axis__ (hax, varargin{:});
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
150 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
151 unwind_protect_cleanup
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
152 if (! isempty (oldfig))
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
153 set (0, "currentfigure", oldfig);
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
154 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
155 end_unwind_protect
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
156
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
157 endfunction
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
158
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
159 function limits = __axis__ (ca, ax, varargin)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
160
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
161 if (nargin == 1)
4945
4bd917f8a4a7 [project @ 2004-08-31 15:09:17 by jwe]
jwe
parents: 4340
diff changeset
162 if (nargout == 0)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
163 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto");
4945
4bd917f8a4a7 [project @ 2004-08-31 15:09:17 by jwe]
jwe
parents: 4340
diff changeset
164 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
165 xlim = get (ca, "xlim");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
166 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
167 view = get (ca, "view");
7b74a7fd4761 axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents: 9357
diff changeset
168 if (view(2) == 90)
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
169 limits = [xlim, ylim];
9427
7b74a7fd4761 axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents: 9357
diff changeset
170 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
171 zlim = get (ca, "zlim");
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
172 limits = [xlim, ylim, zlim];
9427
7b74a7fd4761 axis: return 4-element vector for 2-d view
John W. Eaton <jwe@octave.org>
parents: 9357
diff changeset
173 endif
4945
4bd917f8a4a7 [project @ 2004-08-31 15:09:17 by jwe]
jwe
parents: 4340
diff changeset
174 endif
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
175
5443
ec8c33dcd1bf [project @ 2005-09-08 01:40:57 by jwe]
jwe
parents: 5307
diff changeset
176 elseif (ischar (ax))
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
177 len = length (ax);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
178
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
179 ## '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
180 if (strcmpi (ax, "ij"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
181 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
182 elseif (strcmpi (ax, "xy"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
183 set (ca, "ydir", "normal");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
184
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
185 ## aspect ratio
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
186 elseif (strcmpi (ax, "image"))
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
187 __axis__ (ca, "equal");
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
188 __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
189 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
190 set (ca, "plotboxaspectratio", [1, 1, 1]);
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14247
diff changeset
191 elseif (strcmp (ax, "equal"))
11577
b124b83e5626 fix typo
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
192 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
193 ## FIXME - gnuplot applies the aspect ratio activepostionproperty.
2ab8cc6dcced Special treatment activepositionproperty = outerposition for gnuplot.
Ben Abbott <bpabbott@mac.com>
parents: 10953
diff changeset
194 set (ca, "activepositionproperty", "position");
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11577
diff changeset
195 ## 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
196 ## 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
197 ## (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
198 set (ca, "dataaspectratiomode", "auto");
11001
2ab8cc6dcced Special treatment activepositionproperty = outerposition for gnuplot.
Ben Abbott <bpabbott@mac.com>
parents: 10953
diff changeset
199 endif
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
200 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
201 elseif (strcmpi (ax, "normal"))
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
202 set (ca, "plotboxaspectratio", [1, 1, 1]);
10226
2884758e265b Replace dataaspectratio props with plotboxaspectratio props.
Ben Abbott <bpabbott@mac.com>
parents: 9427
diff changeset
203 set (ca, "plotboxaspectratiomode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
204
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
205 ## axis limits
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
206 elseif (len >= 4 && strcmpi (ax(1:4), "auto"))
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
207 if (len > 4)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
208 if (any (ax == "x"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
209 set (ca, "xlimmode", "auto");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
210 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
211 if (any (ax == "y"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
212 set (ca, "ylimmode", "auto");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
213 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
214 if (any (ax == "z"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
215 set (ca, "zlimmode", "auto");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
216 endif
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
217 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
218 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
219 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
220 elseif (strcmpi (ax, "manual"))
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
221 ## fixes the axis limits, like axis(axis) should;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
222 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
223 elseif (strcmpi (ax, "tight"))
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
224 ## sets the axis limits to the min and max of all data.
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
225 __do_tight_option__ (ca);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
226 ## tic marks
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
227 elseif (strcmpi (ax, "on") || strcmpi (ax, "tic"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
228 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
229 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
230 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
231 "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
232 endif
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6746
diff changeset
233 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
234 elseif (strcmpi (ax, "off"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
235 set (ca, "xtick", [], "ytick", [], "ztick", []);
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6746
diff changeset
236 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
237 elseif (len > 3 && strcmpi (ax(1:3), "tic"))
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
238 if (any (ax == "x"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
239 set (ca, "xtickmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
240 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
241 set (ca, "xtick", []);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
242 endif
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
243 if (any (ax == "y"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
244 set (ca, "ytickmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
245 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
246 set (ca, "ytick", []);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
247 endif
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
248 if (any (ax == "z"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
249 set (ca, "ztickmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
250 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
251 set (ca, "ztick", []);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
252 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
253 elseif (strcmpi (ax, "label"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
254 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
255 "zticklabelmode", "auto");
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7994
diff changeset
256 elseif (strcmpi (ax, "nolabel"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
257 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
258 elseif (len > 5 && strcmpi (ax(1:5), "label"))
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
259 if (any (ax == "x"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
260 set (ca, "xticklabelmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
261 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
262 set (ca, "xticklabel", "");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
263 endif
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
264 if (any (ax == "y"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
265 set (ca, "yticklabelmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
266 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
267 set (ca, "yticklabel", "");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
268 endif
4340
8aa604426d35 [project @ 2003-02-20 04:01:31 by jwe]
jwe
parents: 4259
diff changeset
269 if (any (ax == "z"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
270 set (ca, "zticklabelmode", "auto");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
271 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10532
diff changeset
272 set (ca, "zticklabel", "");
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
273 endif
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
274
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
275 else
4259
0493a367de6f [project @ 2003-01-02 17:30:14 by jwe]
jwe
parents: 4030
diff changeset
276 warning ("unknown axis option '%s'", ax);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
277 endif
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
278
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3979
diff changeset
279 elseif (isvector (ax))
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
280
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
281 len = length (ax);
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
282
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
283 if (len != 2 && len != 4 && len != 6)
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
284 error ("axis: expecting vector with 2, 4, or 6 elements");
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
285 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
286
5627
0f6a0a85a857 [project @ 2006-02-16 20:13:35 by jwe]
jwe
parents: 5561
diff changeset
287 for i = 1:2:len
13031
d2997525fcb6 Fix for bug #34158.
Ben Abbott <bpabbott@mac.com>
parents: 12642
diff changeset
288 if (ax(i) >= ax(i+1))
d2997525fcb6 Fix for bug #34158.
Ben Abbott <bpabbott@mac.com>
parents: 12642
diff changeset
289 error ("axis: limits(%d) must be less than limits(%d)", i, i+1);
5627
0f6a0a85a857 [project @ 2006-02-16 20:13:35 by jwe]
jwe
parents: 5561
diff changeset
290 endif
0f6a0a85a857 [project @ 2006-02-16 20:13:35 by jwe]
jwe
parents: 5561
diff changeset
291 endfor
0f6a0a85a857 [project @ 2006-02-16 20:13:35 by jwe]
jwe
parents: 5561
diff changeset
292
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
293 if (len > 1)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
294 set (ca, "xlim", [ax(1), ax(2)]);
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
295 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
296
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
297 if (len > 3)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
298 set (ca, "ylim", [ax(3), ax(4)]);
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
299 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
300
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
301 if (len > 5)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 5775
diff changeset
302 set (ca, "zlim", [ax(5), ax(6)]);
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
303 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
304
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
305 else
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
306 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements");
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
307 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
308
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
309 if (! isempty (varargin))
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
310 __axis__ (ca, varargin{:});
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
311 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6257
diff changeset
312
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
313 endfunction
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
314
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
315 function lims = __get_tight_lims__ (ca, ax)
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
316
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
317 ## Get the limits for axis ("tight").
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
318 ## 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
319 kids = findobj (ca, "-property", strcat (ax, "data"));
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
320 ## The data properties for hggroups mirror their children.
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
321 ## Exclude the redundant hgroup values.
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
322 hg_kids = findobj (kids, "type", "hggroup");
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
323 kids = setdiff (kids, hg_kids);
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
324 if (isempty (kids))
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
325 ## 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
326 lims = get (ca, strcat (ax, "lim"));
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
327 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
328 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
329 scale = get (ca, strcat (ax, "scale"));
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
330 if (! iscell (data))
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
331 data = {data};
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14247
diff changeset
332 endif
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
333 if (strcmp (scale, "log"))
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
334 tmp = data;
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
335 data = cellfun (@(x) x(x>0), tmp, "uniformoutput", false);
17426
aa380b380315 axis.m: Fix bug when data sets differ in size and dimension (bug #40036).
Rik <rik@octave.org>
parents: 17386
diff changeset
336 n = cellfun ("isempty", data);
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
337 data(n) = cellfun (@(x) x(x<0), tmp(n), "uniformoutput", false);
13174
bd2cd4fd3edf maint: use specific endif, endfor tokens instead of simple end
John W. Eaton <jwe@octave.org>
parents: 13154
diff changeset
338 endif
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14552
diff changeset
339 data = cellfun (@(x) x(isfinite (x)), data, "uniformoutput", false);
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
340 data = data(! cellfun ("isempty", data));
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
341 if (! isempty (data))
17426
aa380b380315 axis.m: Fix bug when data sets differ in size and dimension (bug #40036).
Rik <rik@octave.org>
parents: 17386
diff changeset
342 ## Change data from cell array of various sizes to a single column vector
aa380b380315 axis.m: Fix bug when data sets differ in size and dimension (bug #40036).
Rik <rik@octave.org>
parents: 17386
diff changeset
343 data = cat (1, cellindexmat (data, ":"){:});
aa380b380315 axis.m: Fix bug when data sets differ in size and dimension (bug #40036).
Rik <rik@octave.org>
parents: 17386
diff changeset
344 lims = [min(data), max(data)];
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
345 else
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
346 lims = [0, 1];
8610
85c9906abfd1 use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents: 8507
diff changeset
347 endif
85c9906abfd1 use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents: 8507
diff changeset
348 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
349
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
350 endfunction
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
351
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
352 function __do_tight_option__ (ca)
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
353
17023
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
354 xlim = __get_tight_lims__ (ca, "x");
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
355 if (all (xlim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
356 xlim = eps () * [-1 1];
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
357 elseif (diff (xlim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
358 xlim = xlim .* (1 + eps () * [-1, 1]);
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
359 endif
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
360 ylim = __get_tight_lims__ (ca, "y");
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
361 if (all (ylim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
362 ylim = eps () * [-1 1];
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
363 elseif (diff (ylim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
364 ylim = ylim .* (1 + eps () * [-1, 1]);
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
365 endif
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
366 set (ca, "xlim", xlim, "ylim", ylim)
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17427
diff changeset
367 nd = __calc_dimensions__ (ca);
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17427
diff changeset
368 is3dview = (get (ca, "view")(2) != 90);
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17427
diff changeset
369 if (nd > 2 && is3dview)
17023
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
370 zlim = __get_tight_lims__ (ca, "z");
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
371 if (all (zlim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
372 zlim = eps () * [-1 1];
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
373 elseif (diff (zlim == 0))
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
374 zlim = zlim .* (1 + eps () * [-1, 1]);
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
375 endif
13a12d01aca5 Avoid tight limits having a span of zero.
bpabbott
parents: 15007
diff changeset
376 set (ca, "zlim", zlim);
11183
ac6a199be45e Leave zlim unchanged during 'axis tight' on 2D plots
Konstantinos Poulios <logari81@googlemail.com>
parents: 11174
diff changeset
377 endif
7376
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
378
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
379 endfunction
b052b844e094 [project @ 2008-01-15 01:18:39 by jwe]
jwe
parents: 7216
diff changeset
380
17045
6dec8dbf8a97 axis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17026
diff changeset
381
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
382 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
383 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
384 %! t = 0:0.01:2*pi;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
385 %! x = sin (t);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
386 %!
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
387 %! subplot (221);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
388 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
389 %! title ('normal plot');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
390 %!
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
391 %! subplot (222);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
392 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
393 %! title ('square plot');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
394 %! axis ('square');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
395 %!
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
396 %! subplot (223);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
397 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
398 %! title ('equal plot');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
399 %! axis ('equal');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
400 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
401 %! subplot (224);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
402 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
403 %! title ('normal plot again');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
404 %! axis ('normal');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
405
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
406 %!demo
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
407 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
408 %! t = 0:0.01:2*pi;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
409 %! x = sin (t);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
410 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
411 %! subplot (121);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
412 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
413 %! title ('ij plot');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
414 %! axis ('ij');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
415 %!
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
416 %! subplot (122);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
417 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
418 %! title ('xy plot');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
419 %! axis ('xy');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
420
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
421 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
422 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
423 %! t = 0:0.01:2*pi;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
424 %! x = sin (t);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
425 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
426 %! subplot (331);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
427 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
428 %! title ('x tics and labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
429 %! axis ('ticx');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
430 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
431 %! subplot (332);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
432 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
433 %! title ('y tics and labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
434 %! axis ('ticy');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
435 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
436 %! subplot (333);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
437 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
438 %! title ('axis off');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
439 %! axis ('off');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
440 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
441 %! subplot (334);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
442 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
443 %! title ('x and y tics, x labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
444 %! axis ('labelx','tic');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
445 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
446 %! subplot (335);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
447 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
448 %! title ('x and y tics, y labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
449 %! axis ('labely','tic');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
450 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
451 %! subplot (336);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
452 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
453 %! title ('all tics but no labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
454 %! axis ('nolabel','tic');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
455 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
456 %! subplot (337);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
457 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
458 %! title ('x tics, no labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
459 %! axis ('nolabel','ticx');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
460 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
461 %! subplot (338);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
462 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
463 %! title ('y tics, no labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
464 %! axis ('nolabel','ticy');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
465 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
466 %! subplot (339);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
467 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
468 %! title ('all tics and labels');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
469 %! axis ('on');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
470
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
471 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
472 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
473 %! t = 0:0.01:2*pi;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
474 %! x = sin (t);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
475 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
476 %! subplot (321);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
477 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
478 %! title ('axes at [0 3 0 1]');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
479 %! axis ([0,3,0,1]);
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
480 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
481 %! subplot (322);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
482 %! plot (t, x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
483 %! title ('auto');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
484 %! axis ('auto');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
485 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
486 %! subplot (323);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
487 %! plot (t, x, ';sine [0:2pi];'); hold on;
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
488 %! plot (-3:3,-3:3, ';line (-3,-3)->(3,3);'); hold off;
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
489 %! title ('manual');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
490 %! axis ('manual');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
491 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
492 %! subplot (324);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
493 %! plot (t, x, ';sine [0:2pi];');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
494 %! title ('axes at [0 3 0 1], then autox');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
495 %! axis ([0,3,0,1]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
496 %! axis ('autox');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
497 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
498 %! subplot (325);
17026
be52288f827b Tweak some plotting demos for messages and spelling.
Rik <rik@octave.org>
parents: 17023
diff changeset
499 %! plot (t, x, ';sine [0:2pi];');
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
500 %! title ('axes at [3 6 0 1], then autoy');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
501 %! axis ([3,6,0,1]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
502 %! axis ('autoy');
3667
f7f94396dd81 [project @ 2000-05-13 06:31:28 by jwe]
jwe
parents: 3426
diff changeset
503 %!
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
504 %! subplot (326);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
505 %! plot (t, sin(t), t, -2*sin(t/2));
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
506 %! axis ('tight');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
507 %! title ('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
508
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
509 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
510 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
511 %! x = 0:0.1:10;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
512 %! plot (x, sin(x));
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
513 %! axis image;
17026
be52288f827b Tweak some plotting demos for messages and spelling.
Rik <rik@octave.org>
parents: 17023
diff changeset
514 %! title ({'image', 'equivalent to "tight" & "equal"'});
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
515
9357
95ec56601497 axis.m: Fix bug for 'axis tight' with multiple surface plots, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 9317
diff changeset
516 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
517 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
518 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
519 %! [x,y,z] = peaks (50);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
520 %! x1 = max (x(:));
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
521 %! pcolor (x-x1, y-x1/2, z);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
522 %! hold on;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
523 %! [x,y,z] = sombrero ();
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
524 %! s = x1 / max (x(:));
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
525 %! pcolor (s*x+x1, s*y+x1/2, 5*z);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
526 %! 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
527
11201
6c8791cb35b1 __go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents: 11191
diff changeset
528 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
529 %! clf;
11201
6c8791cb35b1 __go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents: 11191
diff changeset
530 %! x = -10:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
531 %! plot (x,x, x,-x);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
532 %! set (gca, 'yscale', 'log');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
533 %! legend ({'x >= 1', 'x <= 1'}, 'location', 'north');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
534 %! title ('ylim = [1, 10]');
11201
6c8791cb35b1 __go_draw_axes__.m: Set proper tight axis limits for log scale.
Ben Abbott <bpabbott@mac.com>
parents: 11191
diff changeset
535
13154
0c3b1a359998 Fix bug #33606.
Marco Caliari <marco.caliar@univr.it>
parents: 13031
diff changeset
536 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
537 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
538 %! loglog (1:20, '-s');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
539 %! axis tight;
13154
0c3b1a359998 Fix bug #33606.
Marco Caliari <marco.caliar@univr.it>
parents: 13031
diff changeset
540
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
541 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
542 %! clf;
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
543 %! x = -10:0.1:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
544 %! y = sin (x)./(1 + abs (x)) + 0.1*x - 0.4;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
545 %! plot (x, y);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
546 %! set (gca, 'xaxislocation', 'zero');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
547 %! set (gca, 'yaxislocation', 'zero');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
548 %! box off;
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
549 %! title ({'no plot box', 'xaxislocation = zero, yaxislocation = zero'});
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
550
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
551 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
552 %! clf;
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
553 %! x = -10:0.1:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
554 %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
555 %! plot (x, y);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
556 %! set (gca, 'xaxislocation', 'zero');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
557 %! set (gca, 'yaxislocation', 'left');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
558 %! box off;
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
559 %! title ({'no plot box', 'xaxislocation = zero, yaxislocation = left'});
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
560
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
561 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
562 %! clf;
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
563 %! x = -10:0.1:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
564 %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
565 %! plot (x, y);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
566 %! title ('no plot box');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
567 %! set (gca, 'xaxislocation', 'zero');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
568 %! set (gca, 'yaxislocation', 'right');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
569 %! box off;
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
570 %! title ({'no plot box', 'xaxislocation = zero, yaxislocation = right'});
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
571
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
572 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
573 %! clf;
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
574 %! x = -10:0.1:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
575 %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
576 %! plot (x, y);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
577 %! set (gca, 'xaxislocation', 'bottom');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
578 %! set (gca, 'yaxislocation', 'zero');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
579 %! box off;
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
580 %! title ({'no plot box', 'xaxislocation = bottom, yaxislocation = zero'});
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
581
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
582 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
583 %! clf;
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
584 %! x = -10:0.1:10;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
585 %! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
586 %! plot (x, y);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
587 %! set (gca, 'xaxislocation', 'top');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
588 %! set (gca, 'yaxislocation', 'zero');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
589 %! box off;
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
590 %! title ({'no plot box', 'xaxislocation = top, yaxislocation = zero'});
13322
16a706965ee0 Allow the axis box to be turned off for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 13175
diff changeset
591
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
592 %!test
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
593 %! hf = figure ("visible", "off");
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
594 %! unwind_protect
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
595 %! plot (11:20, [21:24, NaN, -Inf, 27:30]);
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
596 %! hold all;
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
597 %! plot (11:20, 25.5 + rand (10));
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
598 %! axis tight;
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
599 %! assert (axis (), [11 20 21 30]);
14054
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
600 %! unwind_protect_cleanup
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
601 %! close (hf);
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
602 %! end_unwind_protect
ec79cd8359c5 Ignore Inf when determining tight axis limits.
Ben Abbott <bpabbott@mac.com>
parents: 13322
diff changeset
603
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
604 %!test
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
605 %! hf = figure ("visible", "off");
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
606 %! unwind_protect
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
607 %! a = logspace (-5, 1, 10);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
608 %! loglog (a, -a);
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
609 %! axis tight;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
610 %! assert (axis (), [1e-5, 10, -10, -1e-5]);
14063
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
611 %! unwind_protect_cleanup
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
612 %! close (hf);
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
613 %! end_unwind_protect
6875d23ce051 Fix regression of tight axis limits introduced by changeset ec79cd8359c5.
Ben Abbott <bpabbott@mac.com>
parents: 14054
diff changeset
614
17427
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
615 ## Test 'axis tight' with differently oriented, differently numbered data vecs
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
616 ## Bug #40036.
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
617 %!test
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
618 %! hf = figure ("visible", "off");
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
619 %! unwind_protect
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
620 %! Z = peaks (linspace (-3, 3, 49), linspace (-2, 2, 29));
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
621 %! surf (Z);
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
622 %! axis tight;
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
623 %! assert (axis (), [1 49 1 29 min(Z(:)) max(Z(:))]);
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
624 %! unwind_protect_cleanup
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
625 %! close (hf);
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
626 %! end_unwind_protect
15d592c82abc test: Add test for bug #40036 to axis.m
Rik <rik@octave.org>
parents: 17426
diff changeset
627