comparison doc/interpreter/plot.txi @ 3368:a4cd1e9d9962

[project @ 1999-11-20 17:22:48 by jwe]
author jwe
date Sat, 20 Nov 1999 17:23:01 +0000
parents bfe1573bd2ae
children 5b77cf82393c
comparison
equal deleted inserted replaced
3367:0748b03c3510 3368:a4cd1e9d9962
160 @findex shg 160 @findex shg
161 The command @code{shg} is equivalent to executing @code{replot} without 161 The command @code{shg} is equivalent to executing @code{replot} without
162 any arguments. 162 any arguments.
163 @end deffn 163 @end deffn
164 164
165 @defvr {Built-in Variable} automatic_replot 165 @DOCSTRING(automatic_replot)
166 You can tell Octave to redisplay the plot each time anything about it
167 changes by setting the value of the builtin variable
168 @code{automatic_replot} to a nonzero value. Since this is fairly
169 inefficient, the default value is 0.
170 @end defvr
171 166
172 Note that NaN values in the plot data are automatically omitted, and 167 Note that NaN values in the plot data are automatically omitted, and
173 Inf values are converted to a very large value before calling gnuplot. 168 Inf values are converted to a very large value before calling gnuplot.
174 169
175 @c XXX FIXME XXX -- add info about what to do to get plots on remote X 170 @c XXX FIXME XXX -- add info about what to do to get plots on remote X
181 The @sc{Matlab}-style two-dimensional plotting commands are: 176 The @sc{Matlab}-style two-dimensional plotting commands are:
182 177
183 @cindex plotting 178 @cindex plotting
184 @cindex graphics 179 @cindex graphics
185 180
186 @deftypefn {Function File} {} plot (@var{args}) 181 @DOCSTRING(plot)
187 This function produces two-dimensional plots. Many different 182
188 combinations of arguments are possible. The simplest form is 183 @DOCSTRING(hold)
189 184
190 @example 185 @DOCSTRING(ishold)
191 plot (@var{y}) 186
192 @end example 187 @DOCSTRING(clearplot)
193 188
194 @noindent 189 @DOCSTRING(closeplot)
195 where the argument is taken as the set of @var{y} coordinates and the 190
196 @var{x} coordinates are taken to be the indices of the elements, 191 @DOCSTRING(purge_tmp_files)
197 starting with 1. 192
198 193 @DOCSTRING(axis)
199 If more than one argument is given, they are interpreted as
200
201 @example
202 plot (@var{x}, @var{y}, @var{fmt} ...)
203 @end example
204
205 @noindent
206 where @var{y} and @var{fmt} are optional, and any number of argument
207 sets may appear. The @var{x} and @var{y} values are
208 interpreted as follows:
209
210 @itemize @bullet
211 @item
212 If a single data argument is supplied, it is taken as the set of @var{y}
213 coordinates and the @var{x} coordinates are taken to be the indices of
214 the elements, starting with 1.
215
216 @item
217 If the first argument is a vector and the second is a matrix, the
218 the vector is plotted versus the columns (or rows) of the matrix.
219 (using whichever combination matches, with columns tried first.)
220
221 @item
222 If the first argument is a matrix and the second is a vector, the
223 the columns (or rows) of the matrix are plotted versus the vector.
224 (using whichever combination matches, with columns tried first.)
225
226 @item
227 If both arguments are vectors, the elements of @var{y} are plotted versus
228 the elements of @var{x}.
229
230 @item
231 If both arguments are matrices, the columns of @var{y} are plotted
232 versus the columns of @var{x}. In this case, both matrices must have
233 the same number of rows and columns and no attempt is made to transpose
234 the arguments to make the number of rows match.
235
236 If both arguments are scalars, a single point is plotted.
237 @end itemize
238
239 The @var{fmt} argument, if present is interpreted as follows. If
240 @var{fmt} is missing, the default gnuplot line style is assumed.
241
242 @table @samp
243 @item -
244 Set lines plot style (default).
245
246 @item .
247 Set dots plot style.
248
249 @item @@
250 Set points plot style.
251
252 @item -@@
253 Set linespoints plot style.
254
255 @item ^
256 Set impulses plot style.
257
258 @item L
259 Set steps plot style.
260
261 @item #
262 Set boxes plot style.
263
264 @item ~
265 Set errorbars plot style.
266
267 @item #~
268 Set boxerrorbars plot style.
269
270 @item @var{n}
271 Interpreted as the plot color if @var{n} is an integer in the range 1 to
272 6.
273
274 @item @var{nm}
275 If @var{nm} is a two digit integer and @var{m} is an integer in the
276 range 1 to 6, @var{m} is interpreted as the point style. This is only
277 valid in combination with the @code{@@} or @code{-@@} specifiers.
278
279 @item @var{c}
280 If @var{c} is one of @code{"r"}, @code{"g"}, @code{"b"}, @code{"m"},
281 @code{"c"}, or @code{"w"}, it is interpreted as the plot color (red,
282 green, blue, magenta, cyan, or white).
283
284 @item +
285 @itemx *
286 @itemx o
287 @itemx x
288 Used in combination with the points or linespoints styles, set the point
289 style.
290 @end table
291
292 The color line styles have the following meanings on terminals that
293 support color.
294
295 @example
296 Number Gnuplot colors (lines)points style
297 1 red *
298 2 green +
299 3 blue o
300 4 magenta x
301 5 cyan house
302 6 brown there exists
303 @end example
304
305 Here are some plot examples:
306
307 @example
308 plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+")
309 @end example
310
311 This command will plot @code{y} with points of type 2 (displayed as
312 @samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of
313 color 4 (magenta) and @code{y4} with points displayed as @samp{+}.
314
315 @example
316 plot (b, "*")
317 @end example
318
319 This command will plot the data in the variable @code{b} will be plotted
320 with points displayed as @samp{*}.
321 @end deftypefn
322
323 @deftypefn {Function File} {} hold @var{args}
324 Tell Octave to `hold' the current data on the plot when executing
325 subsequent plotting commands. This allows you to execute a series of
326 plot commands and have all the lines end up on the same figure. The
327 default is for each new plot command to clear the plot device first.
328 For example, the command
329
330 @example
331 hold on
332 @end example
333
334 @noindent
335 turns the hold state on. An argument of @code{off} turns the hold state
336 off, and @code{hold} with no arguments toggles the current hold state.
337 @end deftypefn
338
339 @deftypefn {Function File} {} ishold
340 Return 1 if the next line will be added to the current plot, or 0 if
341 the plot device will be cleared before drawing the next line.
342 @end deftypefn
343
344 @deftypefn {Function File} {} clearplot
345 @deftypefnx {Function File} {} clg
346 Clear the plot window and any titles or axis labels. The name
347 @code{clg} is aliased to @code{clearplot} for compatibility with @sc{Matlab}.
348
349 The commands @kbd{gplot clear}, @kbd{gsplot clear}, and @kbd{replot
350 clear} are equivalent to @code{clearplot}. (Previously, commands like
351 @kbd{gplot clear} would evaluate @code{clear} as an ordinary expression
352 and clear all the visible variables.)
353 @end deftypefn
354
355 @deftypefn {Function File} {} closeplot
356 Close stream to the @code{gnuplot} subprocess. If you are using X11,
357 this will close the plot window.
358 @end deftypefn
359
360 @deftypefn {Function File} {} purge_tmp_files
361 Delete the temporary files created by the plotting commands.
362
363 Octave creates temporary data files for @code{gnuplot} and then sends
364 commands to @code{gnuplot} through a pipe. Octave will delete the
365 temporary files on exit, but if you are doing a lot of plotting you may
366 want to clean up in the middle of a session.
367
368 A future version of Octave will eliminate the need to use temporary
369 files to hold the plot data.
370 @end deftypefn
371
372 @deftypefn {Function File} {} axis (@var{limits})
373 Sets the axis limits for plots.
374
375 The argument @var{limits} should be a 2, 4, or 6 element vector. The
376 first and second elements specify the lower and upper limits for the x
377 axis. The third and fourth specify the limits for the y axis, and the
378 fifth and sixth specify the limits for the z axis.
379
380 With no arguments, @code{axis} turns autoscaling on.
381
382 If your plot is already drawn, then you need to use @code{replot} before
383 the new axis limits will take effect. You can get this to happen
384 automatically by setting the built-in variable @code{automatic_replot}
385 to a nonzero value.
386 @end deftypefn
387 194
388 @node Specialized Two-Dimensional Plots, Three-Dimensional Plotting, Two-Dimensional Plotting, Plotting 195 @node Specialized Two-Dimensional Plots, Three-Dimensional Plotting, Two-Dimensional Plotting, Plotting
389 @section Specialized Two-Dimensional Plots 196 @section Specialized Two-Dimensional Plots
390 197
391 @deftypefn {Function File} {} bar (@var{x}, @var{y}) 198 @DOCSTRING(bar)
392 Given two vectors of x-y data, @code{bar} produces a bar graph. 199
393 200 @DOCSTRING(contour)
394 If only one argument is given, it is taken as a vector of y-values 201
395 and the x coordinates are taken to be the indices of the elements. 202 @DOCSTRING(hist)
396 203
397 If two output arguments are specified, the data are generated but 204 @DOCSTRING(loglog)
398 not plotted. For example, 205
399 206 @DOCSTRING(polar)
400 @example 207
401 bar (x, y); 208 @DOCSTRING(semilogx)
402 @end example 209
403 210 @DOCSTRING(semilogy)
404 @noindent 211
405 and 212 @DOCSTRING(stairs)
406
407 @example
408 [xb, yb] = bar (x, y);
409 plot (xb, yb);
410 @end example
411
412 @noindent
413 are equivalent.
414 @end deftypefn
415
416 @deftypefn {Function File} {} contour (@var{z}, @var{n}, @var{x}, @var{y})
417 Make a contour plot of the three-dimensional surface described by
418 @var{z}. Someone needs to improve @code{gnuplot}'s contour routines
419 before this will be very useful.
420 @end deftypefn
421
422 @deftypefn {Function File} {} hist (@var{y}, @var{x})
423 Produce histogram counts or plots.
424
425 With one vector input argument, plot a histogram of the values with
426 10 bins. The range of the histogram bins is determined by the range
427 of the data.
428
429 Given a second scalar argument, use that as the number of bins.
430
431 Given a second vector argument, use that as the centers of the bins,
432 with the width of the bins determined from the adjacent values in
433 the vector.
434
435 Extreme values are lumped in the first and last bins.
436
437 With two output arguments, produce the values @var{nn} and @var{xx} such
438 that @code{bar (@var{xx}, @var{nn})} will plot the histogram.
439 @end deftypefn
440
441 @deftypefn {Function File} {} loglog (@var{args})
442 Make a two-dimensional plot using log scales for both axes. See the
443 description of @code{plot} above for a description of the arguments that
444 @code{loglog} will accept.
445 @end deftypefn
446
447 @deftypefn {Function File} {} polar (@var{theta}, @var{rho})
448 Make a two-dimensional plot given polar the coordinates @var{theta} and
449 @var{rho}.
450 @end deftypefn
451
452 @deftypefn {Function File} {} semilogx (@var{args})
453 Make a two-dimensional plot using a log scale for the @var{x} axis. See
454 the description of @code{plot} above for a description of the arguments
455 that @code{semilogx} will accept.
456 @end deftypefn
457
458 @deftypefn {Function File} {} semilogy (@var{args})
459 Make a two-dimensional plot using a log scale for the @var{y} axis. See
460 the description of @code{plot} above for a description of the arguments
461 that @code{semilogy} will accept.
462 @end deftypefn
463
464 @deftypefn {Function File} {} stairs (@var{x}, @var{y})
465 Given two vectors of x-y data, bar produces a `stairstep' plot.
466
467 If only one argument is given, it is taken as a vector of y-values
468 and the x coordinates are taken to be the indices of the elements.
469
470 If two output arguments are specified, the data are generated but
471 not plotted. For example,
472
473 @example
474 stairs (x, y);
475 @end example
476
477 @noindent
478 and
479
480 @example
481 [xs, ys] = stairs (x, y);
482 plot (xs, ys);
483 @end example
484
485 @noindent
486 are equivalent.
487 @end deftypefn
488 213
489 @node Three-Dimensional Plotting, Plot Annotations, Specialized Two-Dimensional Plots, Plotting 214 @node Three-Dimensional Plotting, Plot Annotations, Specialized Two-Dimensional Plots, Plotting
490 @section Three-Dimensional Plotting 215 @section Three-Dimensional Plotting
491 216
492 @deffn {Command} gsplot @var{ranges} @var{expression} @var{using} @var{title} @var{style} 217 @deffn {Command} gsplot @var{ranges} @var{expression} @var{using} @var{title} @var{style}
561 but not @code{rand (5, 30)}. 286 but not @code{rand (5, 30)}.
562 @end deffn 287 @end deffn
563 288
564 The @sc{Matlab}-style three-dimensional plotting commands are: 289 The @sc{Matlab}-style three-dimensional plotting commands are:
565 290
566 @deftypefn {Function File} {} mesh (@var{x}, @var{y}, @var{z}) 291 @DOCSTRING(mesh)
567 Plot a mesh given matrices @code{x}, and @var{y} from @code{meshdom} and 292
568 a matrix @var{z} corresponding to the @var{x} and @var{y} coordinates of 293 @DOCSTRING(meshdom)
569 the mesh. 294
570 @end deftypefn 295 @DOCSTRING(gnuplot_binary)
571 296
572 @deftypefn {Function File} {} meshdom (@var{x}, @var{y}) 297 @DOCSTRING(gnuplot_has_frames)
573 Given vectors of @var{x} and @var{y} coordinates, return two matrices 298
574 corresponding to the @var{x} and @var{y} coordinates of the mesh. 299 @DOCSTRING(figure)
575 300
576 See the file @file{sombrero.m} for an example of using @code{mesh} and 301 @DOCSTRING(gnuplot_has_multiplot)
577 @code{meshdom}.
578 @end deftypefn
579
580 @defvr {Built-in Variable} gnuplot_binary
581 The name of the program invoked by the plot command. The default value
582 is @code{"gnuplot"}. @xref{Installation}.
583 @end defvr
584
585 @defvr {Built-in Variable} gnuplot_has_frames
586 If the value of this variable is nonzero, Octave assumes that your copy
587 of gnuplot has support for multiple frames that is included in recent
588 3.6beta releases. It's initial value is determined by configure, but it
589 can be changed in your startup script or at the command line in case
590 configure got it wrong, or if you upgrade your gnuplot installation.
591 @end defvr
592
593 @deftypefn {Function File} {} figure (@var{n})
594 Set the current plot window to plot window @var{n}. This function
595 currently requires X11 and a version of gnuplot that supports multiple
596 frames.
597 @end deftypefn
598
599 @defvr {Built-in Variable} gnuplot_has_multiplot
600 If the value of this variable is nonzero, Octave assumes that your copy
601 of gnuplot has the multiplot support that is included in recent
602 3.6beta releases. It's initial value is determined by configure, but it
603 can be changed in your startup script or at the command line in case
604 configure got it wrong, or if you upgrade your gnuplot installation.
605 @end defvr
606 302
607 @node Plot Annotations, Multiple Plots on One Page, Three-Dimensional Plotting, Plotting 303 @node Plot Annotations, Multiple Plots on One Page, Three-Dimensional Plotting, Plotting
608 @section Plot Annotations 304 @section Plot Annotations
609 305
610 @deftypefn {Function File} {} grid 306 @DOCSTRING(grid)
611 For two-dimensional plotting, force the display of a grid on the plot. 307
612 @end deftypefn 308 @DOCSTRING(title)
613 309
614 @deftypefn {Function File} {} title (@var{string}) 310 @DOCSTRING(xlabel)
615 Specify a title for the plot. If you already have a plot displayed, use
616 the command @code{replot} to redisplay it with the new title.
617 @end deftypefn
618
619 @deftypefn {Function File} {} xlabel (@var{string})
620 @deftypefnx {Function File} {} ylabel (@var{string})
621 @deftypefnx {Function File} {} zlabel (@var{string})
622 Specify x, y, and z axis labels for the plot. If you already have a plot
623 displayed, use the command @code{replot} to redisplay it with the new
624 labels.
625 @end deftypefn
626 311
627 @node Multiple Plots on One Page, , Plot Annotations, Plotting 312 @node Multiple Plots on One Page, , Plot Annotations, Plotting
628 @section Multiple Plots on One Page 313 @section Multiple Plots on One Page
629 314
630 The following functions all require a version of @code{gnuplot} that 315 The following functions all require a version of @code{gnuplot} that
631 supports the multiplot feature. 316 supports the multiplot feature.
632 317
633 @deftypefn {Function File} {} mplot (@var{x}, @var{y}) 318 @DOCSTRING(mplot)
634 @deftypefnx {Function File} {} mplot (@var{x}, @var{y}, @var{fmt}) 319
635 @deftypefnx {Function File} {} mplot (@var{x1}, @var{y1}, @var{x2}, @var{y2}) 320 @DOCSTRING(multiplot)
636 This is a modified version of the @code{plot} function that works with 321
637 the multiplot version of @code{gnuplot} to plot multiple plots per page. 322 @DOCSTRING(oneplot)
638 This plot version automatically advances to the next subplot position 323
639 after each set of arguments are processed. 324 @DOCSTRING(plot_border)
640 325
641 See the description of the @var{plot} function for the various options. 326 @DOCSTRING(subplot)
642 @end deftypefn 327
643 328 @DOCSTRING(subwindow)
644 @deftypefn {Function File} {} multiplot (@var{xn}, @var{yn}) 329
645 Sets and resets multiplot mode. 330 @DOCSTRING(top_title)
646
647 If the arguments are non-zero, @code{multiplot} will set up multiplot
648 mode with @var{xn}, @var{yn} subplots along the @var{x} and @var{y}
649 axes. If both arguments are zero, @code{multiplot} closes multiplot
650 mode.
651 @end deftypefn
652
653 @deftypefn {Function File} {} oneplot ()
654 If in multiplot mode, switches to single plot mode.
655 @end deftypefn
656
657 @deftypefn {Function File} {} plot_border (...)
658 Multiple arguments allowed to specify the sides on which the border
659 is shown. Allowed arguments include:
660
661 @table @code
662 @item "blank"
663 No borders displayed.
664
665 @item "all"
666 All borders displayed
667
668 @item "north"
669 North Border
670
671 @item "south"
672 South Border
673
674 @item "east"
675 East Border
676
677 @item "west"
678 West Border
679 @end table
680
681 @noindent
682 The arguments may be abbreviated to single characters. Without any
683 arguments, @code{plot_border} turns borders off.
684 @end deftypefn
685
686 @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
687 @deftypefnx {Function File} {} subplot (@var{rcn})
688 Sets @code{gnuplot} in multiplot mode and plots in location
689 given by index (there are @var{cols} by @var{rows} subwindows).
690
691 Input:
692
693 @table @var
694 @item rows
695 Number of rows in subplot grid.
696
697 @item columns
698 Number of columns in subplot grid.
699
700 @item index
701 Index of subplot where to make the next plot.
702 @end table
703
704 If only one argument is supplied, then it must be a three digit value
705 specifying the location in digits 1 (rows) and 2 (columns) and the plot
706 index in digit 3.
707
708 The plot index runs row-wise. First all the columns in a row are filled
709 and then the next row is filled.
710
711 For example, a plot with 4 by 2 grid will have plot indices running as
712 follows:
713 @iftex
714 @tex
715 \vskip 10pt
716 \hfil\vbox{\offinterlineskip\hrule
717 \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr
718 height13pt&1&2&3&4\cr height12pt&&&&\cr\noalign{\hrule}
719 height13pt&5&6&7&8\cr height12pt&&&&\cr\noalign{\hrule}}}
720 \hfil
721 \vskip 10pt
722 @end tex
723 @end iftex
724 @ifinfo
725 @display
726 @group
727 +-----+-----+-----+-----+
728 | 1 | 2 | 3 | 4 |
729 +-----+-----+-----+-----+
730 | 5 | 6 | 7 | 8 |
731 +-----+-----+-----+-----+
732 @end group
733 @end display
734 @end ifinfo
735 @end deftypefn
736
737 @deftypefn {Function File} {} subwindow (@var{xn}, @var{yn})
738 Sets the subwindow position in multiplot mode for the next plot. The
739 multiplot mode has to be previously initialized using the
740 @code{multiplot} function, otherwise this command just becomes an alias
741 to @code{multiplot}
742 @end deftypefn
743
744 @deftypefn {Function File} {} top_title (@var{string})
745 @deftypefnx {Function File} {} bottom_title (@var{string})
746 Makes a title with text @var{string} at the top (bottom) of the plot.
747 @end deftypefn