Mercurial > hg > octave-lyh
annotate scripts/plot/plot.m @ 10121:b5cc666da6ca
Support the '@' marker that was present in Octave 2.1.x
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sat, 16 Jan 2010 07:59:52 +0100 |
parents | 16f53d29049f |
children | a8ce6bdecce5 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004, |
9245 | 2 ## 2005, 2006, 2007, 2008, 2009 John W. Eaton |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
245 | 19 |
3368 | 20 ## -*- texinfo -*- |
6895 | 21 ## @deftypefn {Function File} {} plot (@var{y}) |
22 ## @deftypefnx {Function File} {} plot (@var{x}, @var{y}) | |
23 ## @deftypefnx {Function File} {} plot (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) | |
24 ## @deftypefnx {Function File} {} plot (@var{x}, @var{y}, @var{fmt}) | |
25 ## @deftypefnx {Function File} {} plot (@var{h}, @dots{}) | |
26 ## Produces two-dimensional plots. Many different combinations of | |
27 ## arguments are possible. The simplest form is | |
3426 | 28 ## |
3368 | 29 ## @example |
30 ## plot (@var{y}) | |
31 ## @end example | |
3426 | 32 ## |
3368 | 33 ## @noindent |
34 ## where the argument is taken as the set of @var{y} coordinates and the | |
35 ## @var{x} coordinates are taken to be the indices of the elements, | |
36 ## starting with 1. | |
3426 | 37 ## |
5798 | 38 ## To save a plot, in one of several image formats such as PostScript |
39 ## or PNG, use the @code{print} command. | |
40 ## | |
3368 | 41 ## If more than one argument is given, they are interpreted as |
3426 | 42 ## |
3368 | 43 ## @example |
6895 | 44 ## plot (@var{y}, @var{property}, @var{value}, @dots{}) |
3368 | 45 ## @end example |
3426 | 46 ## |
3368 | 47 ## @noindent |
6895 | 48 ## or |
6459 | 49 ## |
50 ## @example | |
51 ## plot (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) | |
52 ## @end example | |
53 ## | |
54 ## @noindent | |
6895 | 55 ## or |
56 ## | |
57 ## @example | |
58 ## plot (@var{x}, @var{y}, @var{fmt}, @dots{}) | |
59 ## @end example | |
60 ## | |
61 ## @noindent | |
62 ## and so on. Any number of argument sets may appear. The @var{x} and | |
63 ## @var{y} values are interpreted as follows: | |
3426 | 64 ## |
3368 | 65 ## @itemize @bullet |
66 ## @item | |
67 ## If a single data argument is supplied, it is taken as the set of @var{y} | |
68 ## coordinates and the @var{x} coordinates are taken to be the indices of | |
69 ## the elements, starting with 1. | |
3426 | 70 ## |
3368 | 71 ## @item |
6672 | 72 ## If the @var{x} is a vector and @var{y} is a matrix, then |
6177 | 73 ## the columns (or rows) of @var{y} are plotted versus @var{x}. |
2311 | 74 ## (using whichever combination matches, with columns tried first.) |
3426 | 75 ## |
3368 | 76 ## @item |
6177 | 77 ## If the @var{x} is a matrix and @var{y} is a vector, |
78 ## @var{y} is plotted versus the columns (or rows) of @var{x}. | |
2311 | 79 ## (using whichever combination matches, with columns tried first.) |
3426 | 80 ## |
3368 | 81 ## @item |
82 ## If both arguments are vectors, the elements of @var{y} are plotted versus | |
83 ## the elements of @var{x}. | |
3426 | 84 ## |
3368 | 85 ## @item |
86 ## If both arguments are matrices, the columns of @var{y} are plotted | |
87 ## versus the columns of @var{x}. In this case, both matrices must have | |
88 ## the same number of rows and columns and no attempt is made to transpose | |
89 ## the arguments to make the number of rows match. | |
3426 | 90 ## |
2311 | 91 ## If both arguments are scalars, a single point is plotted. |
3368 | 92 ## @end itemize |
3426 | 93 ## |
6895 | 94 ## Multiple property-value pairs may be specified, but they must appear |
95 ## in pairs. These arguments are applied to the lines drawn by | |
96 ## @code{plot}. | |
97 ## | |
3368 | 98 ## If the @var{fmt} argument is supplied, it is interpreted as |
99 ## follows. If @var{fmt} is missing, the default gnuplot line style | |
100 ## is assumed. | |
3426 | 101 ## |
3368 | 102 ## @table @samp |
103 ## @item - | |
104 ## Set lines plot style (default). | |
3426 | 105 ## |
3368 | 106 ## @item . |
107 ## Set dots plot style. | |
3426 | 108 ## |
3368 | 109 ## @item @var{n} |
110 ## Interpreted as the plot color if @var{n} is an integer in the range 1 to | |
111 ## 6. | |
3426 | 112 ## |
3368 | 113 ## @item @var{nm} |
114 ## If @var{nm} is a two digit integer and @var{m} is an integer in the | |
115 ## range 1 to 6, @var{m} is interpreted as the point style. This is only | |
116 ## valid in combination with the @code{@@} or @code{-@@} specifiers. | |
3426 | 117 ## |
3368 | 118 ## @item @var{c} |
6177 | 119 ## If @var{c} is one of @code{"k"} (black), @code{"r"} (red), @code{"g"} |
120 ## (green), @code{"b"} (blue), @code{"m"} (magenta), @code{"c"} (cyan), | |
121 ## or @code{"w"} (white), it is interpreted as the line plot color. | |
3426 | 122 ## |
3717 | 123 ## @item ";title;" |
124 ## Here @code{"title"} is the label for the key. | |
125 ## | |
3368 | 126 ## @item + |
127 ## @itemx * | |
128 ## @itemx o | |
129 ## @itemx x | |
8088 | 130 ## @itemx ^ |
3368 | 131 ## Used in combination with the points or linespoints styles, set the point |
132 ## style. | |
10121
b5cc666da6ca
Support the '@' marker that was present in Octave 2.1.x
David Bateman <dbateman@free.fr>
parents:
9245
diff
changeset
|
133 ## |
b5cc666da6ca
Support the '@' marker that was present in Octave 2.1.x
David Bateman <dbateman@free.fr>
parents:
9245
diff
changeset
|
134 ## @item @@ |
b5cc666da6ca
Support the '@' marker that was present in Octave 2.1.x
David Bateman <dbateman@free.fr>
parents:
9245
diff
changeset
|
135 ## Select the next unused point style. |
3368 | 136 ## @end table |
3426 | 137 ## |
6895 | 138 ## The @var{fmt} argument may also be used to assign key titles. |
3683 | 139 ## To do so, include the desired title between semi-colons after the |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
140 ## formatting sequence described above, e.g., "+3;Key Title;" |
3683 | 141 ## Note that the last semi-colon is required and will generate an error if |
142 ## it is left out. | |
143 ## | |
3368 | 144 ## Here are some plot examples: |
3426 | 145 ## |
3368 | 146 ## @example |
147 ## plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+") | |
148 ## @end example | |
3426 | 149 ## |
3368 | 150 ## This command will plot @code{y} with points of type 2 (displayed as |
151 ## @samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of | |
152 ## color 4 (magenta) and @code{y4} with points displayed as @samp{+}. | |
3426 | 153 ## |
3368 | 154 ## @example |
6459 | 155 ## plot (b, "*", "markersize", 3) |
3368 | 156 ## @end example |
3426 | 157 ## |
6672 | 158 ## This command will plot the data in the variable @code{b}, |
6459 | 159 ## with points displayed as @samp{*} with a marker size of 3. |
3683 | 160 ## |
161 ## @example | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
162 ## @group |
3683 | 163 ## t = 0:0.1:6.3; |
164 ## plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"); | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
165 ## @end group |
3683 | 166 ## @end example |
167 ## | |
168 ## This will plot the cosine and sine functions and label them accordingly | |
169 ## in the key. | |
6820 | 170 ## |
171 ## If the first argument is an axis handle, then plot into these axes, | |
172 ## rather than the current axis handle returned by @code{gca}. | |
6895 | 173 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, bar, |
174 ## stairs, errorbar, xlabel, ylabel, title, print} | |
3368 | 175 ## @end deftypefn |
4 | 176 |
2314 | 177 ## Author: jwe |
178 | |
6302 | 179 function retval = plot (varargin) |
4 | 180 |
7215 | 181 [h, varargin] = __plt_get_axis_arg__ ("plot", varargin{:}); |
7216 | 182 |
7215 | 183 oldh = gca (); |
184 unwind_protect | |
185 axes (h); | |
6820 | 186 newplot (); |
7215 | 187 tmp = __plt__ ("plot", h, varargin{:}); |
188 unwind_protect_cleanup | |
189 axes (oldh); | |
190 end_unwind_protect | |
6302 | 191 |
192 if (nargout > 0) | |
193 retval = tmp; | |
194 endif | |
4 | 195 |
196 endfunction |