File: octave_15.html

package info (click to toggle)
octave 2.0.16-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 26,276 kB
  • ctags: 16,450
  • sloc: cpp: 67,548; fortran: 41,514; ansic: 26,682; sh: 7,361; makefile: 4,077; lex: 2,008; yacc: 1,849; lisp: 1,702; perl: 1,676; exp: 123
file content (1043 lines) | stat: -rw-r--r-- 27,364 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from ./octave.texi on 18 June 1999 -->

<TITLE>GNU Octave - Plotting</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="octave_1.html">first</A>, <A HREF="octave_14.html">previous</A>, <A HREF="octave_16.html">next</A>, <A HREF="octave_40.html">last</A> section, <A HREF="octave_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC125" HREF="octave_toc.html#TOC125">Plotting</A></H1>

<P>
All of Octave's plotting functions use <CODE>gnuplot</CODE> to handle the
actual graphics.  There are two low-level functions, <CODE>gplot</CODE> and
<CODE>gsplot</CODE>, that behave almost exactly like the corresponding
<CODE>gnuplot</CODE> functions <CODE>plot</CODE> and <CODE>splot</CODE>.  A number of
other higher level plotting functions, patterned after the graphics
functions found in MATLAB version 3.5, are also available.
These higher level functions are all implemented in terms of the two
low-level plotting functions.

</P>



<H2><A NAME="SEC126" HREF="octave_toc.html#TOC126">Two-Dimensional Plotting</A></H2>

<P>
<DL>
<DT><U>Command:</U> <B>gplot</B> <I><VAR>ranges</VAR> <VAR>expression</VAR> <VAR>using</VAR> <VAR>title</VAR> <VAR>style</VAR></I>
<DD><A NAME="IDX525"></A>
Generate a 2-dimensional plot.

</P>
<P>
The <VAR>ranges</VAR>, <VAR>using</VAR>, <VAR>title</VAR>, and <VAR>style</VAR> arguments
are optional, and the <VAR>using</VAR>, <VAR>title</VAR> and <VAR>style</VAR>
qualifiers may appear in any order after the expression.  You may plot
multiple expressions with a single command by separating them with
commas.  Each expression may have its own set of qualifiers.

</P>
<P>
The optional item <VAR>ranges</VAR> has the syntax

</P>

<PRE>
[ x_lo : x_up ] [ y_lo : y_up ]
</PRE>

<P>
and may be used to specify the ranges for the axes of the plot,
independent of the actual range of the data.  The range for the y axes
and any of the individual limits may be omitted.  A range <CODE>[:]</CODE>
indicates that the default limits should be used.  This normally means
that a range just large enough to include all the data points will be
used.

</P>
<P>
The expression to be plotted must not contain any literal matrices
(e.g. <CODE>[ 1, 2; 3, 4 ]</CODE>) since it is nearly impossible to
distinguish a plot range from a matrix of data.

</P>
<P>
See the help for <CODE>gnuplot</CODE> for a description of the syntax for the
optional items.

</P>
<P>
By default, the <CODE>gplot</CODE> command plots the second column of a matrix
versus the first.  If the matrix only has one column, it is taken as a
vector of y-coordinates and the x-coordinate is taken as the element
index, starting with zero.  For example,

</P>

<PRE>
gplot rand (100,1) with linespoints
</PRE>

<P>
will plot 100 random values and connect them with lines.  When
<CODE>gplot</CODE> is used to plot a column vector, the indices of the
elements are taken as x values.

</P>
<P>
  If there are more than two columns, you can
choose which columns to plot with the <VAR>using</VAR> qualifier. For
example, given the data

</P>

<PRE>
x = (-10:0.1:10)';
data = [x, sin(x), cos(x)];
</PRE>

<P>
the command

</P>

<PRE>
gplot [-11:11] [-1.1:1.1] \
  data with lines, data using 1:3 with impulses
</PRE>

<P>
will plot two lines.  The first line is generated by the command
<CODE>data with lines</CODE>, and is a graph of the sine function over the
range -10 to 10.  The data is taken from the first two columns of
the matrix because columns to plot were not specified with the
<VAR>using</VAR> qualifier.

</P>
<P>
The clause <CODE>using 1:3</CODE> in the second part of this plot command
specifies that the first and third columns of the matrix <CODE>data</CODE>
should be taken as the values to plot.

</P>
<P>
In this example, the ranges have been explicitly specified to be a bit
larger than the actual range of the data so that the curves do not touch
the border of the plot.
</DL>

</P>
<P>
<DL>
<DT><U>Command:</U> <B>gset</B> <I>options</I>
<DD><A NAME="IDX526"></A>
<DT><U>Command:</U> <B>gshow</B> <I>options</I>
<DD><A NAME="IDX527"></A>
<DT><U>Command:</U> <B>replot</B> <I>options</I>
<DD><A NAME="IDX528"></A>
In addition to the basic plotting commands, the whole range of
<CODE>gset</CODE> and <CODE>gshow</CODE> commands from <CODE>gnuplot</CODE> are available,
as is <CODE>replot</CODE>.

</P>
<P>
<A NAME="IDX529"></A>
<A NAME="IDX530"></A>
Note that in Octave 2.0, the <CODE>set</CODE> and <CODE>show</CODE> commands were
renamed to <CODE>gset</CODE> and <CODE>gshow</CODE> in order to allow for
compatibility with the MATLAB graphics and GUI commands in a future
version of Octave.  (For now, the old <CODE>set</CODE> and <CODE>show</CODE>
commands do work, but they print an annoying warning message to try to
get people to switch to using <CODE>gset</CODE> and <CODE>gshow</CODE>.)

</P>
<P>
The <CODE>gset</CODE> and <CODE>gshow</CODE> commands allow you to set and show
<CODE>gnuplot</CODE> parameters.  For more information about the <CODE>gset</CODE>
and <CODE>gshow</CODE> commands, see the documentation for <CODE>set</CODE> and
<CODE>show</CODE> in the <CODE>gnuplot</CODE> user's guide (also available on line
if you run <CODE>gnuplot</CODE> directly, instead of running it from Octave).

</P>
<P>
The <CODE>replot</CODE> command allows you to force the plot to be
redisplayed.  This is useful if you have changed something about the
plot, such as the title or axis labels.  The <CODE>replot</CODE> command also
accepts the same arguments as <CODE>gplot</CODE> or <CODE>gsplot</CODE> (except for
data ranges) so you can add additional lines to existing plots.  

</P>
<P>
For example,

</P>

<PRE>
gset term tek40
gset output "/dev/plotter"
gset title "sine with lines and cosine with impulses"
replot "sin (x) w l"
</PRE>

<P>
will change the terminal type for plotting, add a title to the current
plot, add a graph of
sin (x) 
to the plot, and force the new plot to be
sent to the plot device.  This last step is normally required in order
to update the plot.  This default is reasonable for slow terminals or
hardcopy output devices because even when you are adding additional
lines with a replot command, gnuplot always redraws the entire plot, and
you probably don't want to have a completely new plot generated every
time something as minor as an axis label changes.

</P>
<P>
<A NAME="IDX531"></A>
The command <CODE>shg</CODE> is equivalent to executing <CODE>replot</CODE> without
any arguments.
</DL>

</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>automatic_replot</B>
<DD><A NAME="IDX532"></A>
You can tell Octave to redisplay the plot each time anything about it
changes by setting the value of the builtin variable
<CODE>automatic_replot</CODE> to a nonzero value.  Since this is fairly
inefficient, the default value is 0.
</DL>

</P>
<P>
Note that NaN values in the plot data are automatically omitted, and
Inf values are converted to a very large value before calling gnuplot.

</P>

<P>
The MATLAB-style two-dimensional plotting commands are:

</P>
<P>
<A NAME="IDX533"></A>
<A NAME="IDX534"></A>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>plot</B> <I>(<VAR>args</VAR>)</I>
<DD><A NAME="IDX535"></A>
This function produces two-dimensional plots.  Many different
combinations of arguments are possible.  The simplest form is

</P>

<PRE>
plot (<VAR>y</VAR>)
</PRE>

<P>
where the argument is taken as the set of <VAR>y</VAR> coordinates and the
<VAR>x</VAR> coordinates are taken to be the indices of the elements,
starting with 1.

</P>
<P>
If more than one argument is given, they are interpreted as

</P>

<PRE>
plot (<VAR>x</VAR>, <VAR>y</VAR>, <VAR>fmt</VAR> ...)
</PRE>

<P>
where <VAR>y</VAR> and <VAR>fmt</VAR> are optional, and any number of argument
sets may appear.  The <VAR>x</VAR> and <VAR>y</VAR> values are
interpreted as follows:

</P>

<UL>
<LI>

If a single data argument is supplied, it is taken as the set of <VAR>y</VAR>
coordinates and the <VAR>x</VAR> coordinates are taken to be the indices of
the elements, starting with 1.

<LI>

If the first argument is a vector and the second is a matrix, the
the vector is plotted versus the columns (or rows) of the matrix.
(using whichever combination matches, with columns tried first.)

<LI>

If the first argument is a matrix and the second is a vector, the
the columns (or rows) of the matrix are plotted versus the vector.
(using whichever combination matches, with columns tried first.)

<LI>

If both arguments are vectors, the elements of <VAR>y</VAR> are plotted versus
the elements of <VAR>x</VAR>.

<LI>

If both arguments are matrices, the columns of <VAR>y</VAR> are plotted
versus the columns of <VAR>x</VAR>.  In this case, both matrices must have
the same number of rows and columns and no attempt is made to transpose
the arguments to make the number of rows match.

If both arguments are scalars, a single point is plotted.
</UL>

<P>
The <VAR>fmt</VAR> argument, if present is interpreted as follows.  If
<VAR>fmt</VAR> is missing, the default gnuplot line style is assumed.

</P>
<DL COMPACT>

<DT><SAMP>`-'</SAMP>
<DD>
Set lines plot style (default).

<DT><SAMP>`.'</SAMP>
<DD>
Set dots plot style.

<DT><SAMP>`@'</SAMP>
<DD>
Set points plot style.

<DT><SAMP>`-@'</SAMP>
<DD>
Set linespoints plot style.

<DT><SAMP>`^'</SAMP>
<DD>
Set impulses plot style.

<DT><SAMP>`L'</SAMP>
<DD>
Set steps plot style.

<DT><SAMP>`#'</SAMP>
<DD>
Set boxes plot style.

<DT><SAMP>`~'</SAMP>
<DD>
Set errorbars plot style.

<DT><SAMP>`#~'</SAMP>
<DD>
Set boxerrorbars plot style.

<DT><SAMP>`<VAR>n</VAR>'</SAMP>
<DD>
Interpreted as the plot color if <VAR>n</VAR> is an integer in the range 1 to
6.

<DT><SAMP>`<VAR>nm</VAR>'</SAMP>
<DD>
If <VAR>nm</VAR> is a two digit integer and <VAR>m</VAR> is an integer in the
range 1 to 6, <VAR>m</VAR> is interpreted as the point style.  This is only
valid in combination with the <CODE>@</CODE> or <CODE>-@</CODE> specifiers.

<DT><SAMP>`<VAR>c</VAR>'</SAMP>
<DD>
If <VAR>c</VAR> is one of <CODE>"r"</CODE>, <CODE>"g"</CODE>, <CODE>"b"</CODE>, <CODE>"m"</CODE>,
<CODE>"c"</CODE>, or <CODE>"w"</CODE>, it is interpreted as the plot color (red,
green, blue, magenta, cyan, or white).

<DT><SAMP>`+'</SAMP>
<DD>
<DT><SAMP>`*'</SAMP>
<DD>
<DT><SAMP>`o'</SAMP>
<DD>
<DT><SAMP>`x'</SAMP>
<DD>
Used in combination with the points or linespoints styles, set the point
style.
</DL>

<P>
The color line styles have the following meanings on terminals that
support color.

</P>

<PRE>
Number  Gnuplot colors  (lines)points style
  1       red                   *
  2       green                 +
  3       blue                  o
  4       magenta               x
  5       cyan                house
  6       brown            there exists
</PRE>

<P>
Here are some plot examples:

</P>

<PRE>
plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+")
</PRE>

<P>
This command will plot <CODE>y</CODE> with points of type 2 (displayed as
<SAMP>`+'</SAMP>) and color 1 (red), <CODE>y2</CODE> with lines, <CODE>y3</CODE> with lines of
color 4 (magenta) and <CODE>y4</CODE> with points displayed as <SAMP>`+'</SAMP>.

</P>

<PRE>
plot (b, "*")
</PRE>

<P>
This command will plot the data in the variable <CODE>b</CODE> will be plotted
with points displayed as <SAMP>`*'</SAMP>.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>hold</B> <I><VAR>args</VAR></I>
<DD><A NAME="IDX536"></A>
Tell Octave to `hold' the current data on the plot when executing
subsequent plotting commands.  This allows you to execute a series of
plot commands and have all the lines end up on the same figure.  The
default is for each new plot command to clear the plot device first.
For example, the command

</P>

<PRE>
hold on
</PRE>

<P>
turns the hold state on.  An argument of <CODE>off</CODE> turns the hold state
off, and <CODE>hold</CODE> with no arguments toggles the current hold state.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>ishold</B>
<DD><A NAME="IDX537"></A>
Return 1 if the next line will be added to the current plot, or 0 if
the plot device will be cleared before drawing the next line.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>clearplot</B>
<DD><A NAME="IDX538"></A>
<DT><U>Function File:</U>  <B>clg</B>
<DD><A NAME="IDX539"></A>
Clear the plot window and any titles or axis labels.  The name
<CODE>clg</CODE> is aliased to <CODE>clearplot</CODE> for compatibility with MATLAB.

</P>
<P>
The commands <KBD>gplot clear</KBD>, <KBD>gsplot clear</KBD>, and <KBD>replot
clear</KBD> are equivalent to <CODE>clearplot</CODE>.  (Previously, commands like
<KBD>gplot clear</KBD> would evaluate <CODE>clear</CODE> as an ordinary expression
and clear all the visible variables.)
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>closeplot</B>
<DD><A NAME="IDX540"></A>
Close stream to the <CODE>gnuplot</CODE> subprocess.  If you are using X11,
this will close the plot window.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>purge_tmp_files</B>
<DD><A NAME="IDX541"></A>
Delete the temporary files created by the plotting commands.

</P>
<P>
Octave creates temporary data files for <CODE>gnuplot</CODE> and then sends
commands to <CODE>gnuplot</CODE> through a pipe.  Octave will delete the
temporary files on exit, but if you are doing a lot of plotting you may
want to clean up in the middle of a session.

</P>
<P>
A future version of Octave will eliminate the need to use temporary
files to hold the plot data.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>axis</B> <I>(<VAR>limits</VAR>)</I>
<DD><A NAME="IDX542"></A>
Sets the axis limits for plots.

</P>
<P>
The argument <VAR>limits</VAR> should be a 2, 4, or 6 element vector.  The
first and second elements specify the lower and upper limits for the x
axis.  The third and fourth specify the limits for the y axis, and the
fifth and sixth specify the limits for the z axis.

</P>
<P>
With no arguments, <CODE>axis</CODE> turns autoscaling on.

</P>
<P>
If your plot is already drawn, then you need to use <CODE>replot</CODE> before
the new axis limits will take effect.  You can get this to happen
automatically by setting the built-in variable <CODE>automatic_replot</CODE>
to a nonzero value.
</DL>

</P>


<H2><A NAME="SEC127" HREF="octave_toc.html#TOC127">Specialized Two-Dimensional Plots</A></H2>

<P>
<DL>
<DT><U>Function File:</U>  <B>bar</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX543"></A>
Given two vectors of x-y data, <CODE>bar</CODE> produces a bar graph.

</P>
<P>
If only one argument is given, it is taken as a vector of y-values
and the x coordinates are taken to be the indices of the elements.

</P>
<P>
If two output arguments are specified, the data are generated but
not plotted.  For example,

</P>

<PRE>
bar (x, y);
</PRE>

<P>
and

</P>

<PRE>
[xb, yb] = bar (x, y);
plot (xb, yb);
</PRE>

<P>
are equivalent.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>contour</B> <I>(<VAR>z</VAR>, <VAR>n</VAR>, <VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX544"></A>
Make a contour plot of the three-dimensional surface described by
<VAR>z</VAR>.  Someone needs to improve <CODE>gnuplot</CODE>'s contour routines
before this will be very useful.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>hist</B> <I>(<VAR>y</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX545"></A>
Produce histogram counts or plots.

</P>
<P>
With one vector input argument, plot a histogram of the values with
10 bins.  The range of the histogram bins is determined by the range
of the data.

</P>
<P>
Given a second scalar argument, use that as the number of bins.

</P>
<P>
Given a second vector argument, use that as the centers of the bins,
with the width of the bins determined from the adjacent values in
the vector.

</P>
<P>
Extreme values are lumped in the first and last bins.

</P>
<P>
With two output arguments, produce the values <VAR>nn</VAR> and <VAR>xx</VAR> such
that <CODE>bar (<VAR>xx</VAR>, <VAR>nn</VAR>)</CODE> will plot the histogram.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>loglog</B> <I>(<VAR>args</VAR>)</I>
<DD><A NAME="IDX546"></A>
Make a two-dimensional plot using log scales for both axes.  See the
description of <CODE>plot</CODE> above for a description of the arguments that
<CODE>loglog</CODE> will accept.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>polar</B> <I>(<VAR>theta</VAR>, <VAR>rho</VAR>)</I>
<DD><A NAME="IDX547"></A>
Make a two-dimensional plot given polar the coordinates <VAR>theta</VAR> and
<VAR>rho</VAR>.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>semilogx</B> <I>(<VAR>args</VAR>)</I>
<DD><A NAME="IDX548"></A>
Make a two-dimensional plot using a log scale for the <VAR>x</VAR> axis.  See
the description of <CODE>plot</CODE> above for a description of the arguments
that <CODE>semilogx</CODE> will accept.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>semilogy</B> <I>(<VAR>args</VAR>)</I>
<DD><A NAME="IDX549"></A>
Make a two-dimensional plot using a log scale for the <VAR>y</VAR> axis.  See
the description of <CODE>plot</CODE> above for a description of the arguments
that <CODE>semilogy</CODE> will accept.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>stairs</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX550"></A>
Given two vectors of x-y data, bar produces a `stairstep' plot.

</P>
<P>
If only one argument is given, it is taken as a vector of y-values
and the x coordinates are taken to be the indices of the elements.

</P>
<P>
If two output arguments are specified, the data are generated but
not plotted.  For example,

</P>

<PRE>
stairs (x, y);
</PRE>

<P>
and

</P>

<PRE>
[xs, ys] = stairs (x, y);
plot (xs, ys);
</PRE>

<P>
are equivalent.
</DL>

</P>


<H2><A NAME="SEC128" HREF="octave_toc.html#TOC128">Three-Dimensional Plotting</A></H2>

<P>
<DL>
<DT><U>Command:</U> <B>gsplot</B> <I><VAR>ranges</VAR> <VAR>expression</VAR> <VAR>using</VAR> <VAR>title</VAR> <VAR>style</VAR></I>
<DD><A NAME="IDX551"></A>
Generate a 3-dimensional plot.

</P>
<P>
The <VAR>ranges</VAR>, <VAR>using</VAR>, <VAR>title</VAR>, and <VAR>style</VAR> arguments
are optional, and the <VAR>using</VAR>, <VAR>title</VAR> and <VAR>style</VAR>
qualifiers may appear in any order after the expression.  You may plot
multiple expressions with a single command by separating them with
commas.  Each expression may have its own set of qualifiers.

</P>
<P>
The optional item <VAR>ranges</VAR> has the syntax

</P>

<PRE>
[ x_lo : x_up ] [ y_lo : y_up ] [ z_lo : z_up ]
</PRE>

<P>
and may be used to specify the ranges for the axes of the plot,
independent of the actual range of the data.  The range for the y and z
axes and any of the individual limits may be omitted.  A range
<CODE>[:]</CODE> indicates that the default limits should be used.  This
normally means that a range just large enough to include all the data
points will be used.

</P>
<P>
The expression to be plotted must not contain any literal matrices (e.g.
<CODE>[ 1, 2; 3, 4 ]</CODE>) since it is nearly impossible to distinguish a
plot range from a matrix of data.

</P>
<P>
See the help for <CODE>gnuplot</CODE> for a description of the syntax for the
optional items.

</P>
<P>
By default, the <CODE>gsplot</CODE> command plots each column of the
expression as the z value, using the row index as the x value, and the
column index as the y value.  The indices are counted from zero, not
one.  For example,

</P>

<PRE>
gsplot rand (5, 2)
</PRE>

<P>
will plot a random surface, with the x and y values taken from the row
and column indices of the matrix.

</P>
<P>
If parametric plotting mode is set (using the command
<KBD>gset parametric</KBD>, then <CODE>gsplot</CODE> takes the columns of the
matrix three at a time as the x, y and z values that define a line in
three space.  Any extra columns are ignored, and the x and y values are
expected to be sorted.  For example, with <CODE>parametric</CODE> set, it
makes sense to plot a matrix like

</P>

<PRE>
1 1 3 2 1 6 3 1 9
1 2 2 2 2 5 3 2 8
1 3 1 2 3 4 3 3 7
</PRE>

<P>
but not <CODE>rand (5, 30)</CODE>.
</DL>

</P>
<P>
The MATLAB-style three-dimensional plotting commands are:

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>mesh</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>, <VAR>z</VAR>)</I>
<DD><A NAME="IDX552"></A>
Plot a mesh given matrices <CODE>x</CODE>, and <VAR>y</VAR> from <CODE>meshdom</CODE> and
a matrix <VAR>z</VAR> corresponding to the <VAR>x</VAR> and <VAR>y</VAR> coordinates of
the mesh.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>meshdom</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX553"></A>
Given vectors of <VAR>x</VAR> and <VAR>y</VAR> coordinates, return two matrices
corresponding to the <VAR>x</VAR> and <VAR>y</VAR> coordinates of the mesh.

</P>
<P>
See the file <TT>`sombrero.m'</TT> for an example of using <CODE>mesh</CODE> and
<CODE>meshdom</CODE>.
</DL>

</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>gnuplot_binary</B>
<DD><A NAME="IDX554"></A>
The name of the program invoked by the plot command.  The default value
is <CODE>"gnuplot"</CODE>.  See section <A HREF="octave_33.html#SEC189">Installing Octave</A>.
</DL>

</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>gnuplot_has_frames</B>
<DD><A NAME="IDX555"></A>
If the value of this variable is nonzero, Octave assumes that your copy
of gnuplot has support for multiple frames that is included in recent
3.6beta releases.  It's initial value is determined by configure, but it
can be changed in your startup script or at the command line in case
configure got it wrong, or if you upgrade your gnuplot installation.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>figure</B> <I>(<VAR>n</VAR>)</I>
<DD><A NAME="IDX556"></A>
Set the current plot window to plot window <VAR>n</VAR>.  This function
currently requires X11 and a version of gnuplot that supports multiple
frames.
</DL>

</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>gnuplot_has_multiplot</B>
<DD><A NAME="IDX557"></A>
If the value of this variable is nonzero, Octave assumes that your copy
of gnuplot has the multiplot support that is included in recent
3.6beta releases.  It's initial value is determined by configure, but it
can be changed in your startup script or at the command line in case
configure got it wrong, or if you upgrade your gnuplot installation.
</DL>

</P>


<H2><A NAME="SEC129" HREF="octave_toc.html#TOC129">Plot Annotations</A></H2>

<P>
<DL>
<DT><U>Function File:</U>  <B>grid</B>
<DD><A NAME="IDX558"></A>
For two-dimensional plotting, force the display of a grid on the plot.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>title</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX559"></A>
Specify a title for the plot.  If you already have a plot displayed, use
the command <CODE>replot</CODE> to redisplay it with the new title.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>xlabel</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX560"></A>
<DT><U>Function File:</U>  <B>ylabel</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX561"></A>
<DT><U>Function File:</U>  <B>zlabel</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX562"></A>
Specify x, y, and z axis labels for the plot.  If you already have a plot
displayed, use the command <CODE>replot</CODE> to redisplay it with the new
labels.
</DL>

</P>


<H2><A NAME="SEC130" HREF="octave_toc.html#TOC130">Multiple Plots on One Page</A></H2>

<P>
The following functions all require a version of <CODE>gnuplot</CODE> that
supports the multiplot feature.

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>mplot</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX563"></A>
<DT><U>Function File:</U>  <B>mplot</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>, <VAR>fmt</VAR>)</I>
<DD><A NAME="IDX564"></A>
<DT><U>Function File:</U>  <B>mplot</B> <I>(<VAR>x1</VAR>, <VAR>y1</VAR>, <VAR>x2</VAR>, <VAR>y2</VAR>)</I>
<DD><A NAME="IDX565"></A>
This is a modified version of the <CODE>plot</CODE> function that works with
the multiplot version of <CODE>gnuplot</CODE> to plot multiple plots per page. 
This plot version automatically advances to the next subplot position
after each set of arguments are processed.

</P>
<P>
See the description of the <VAR>plot</VAR> function for the various options.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>multiplot</B> <I>(<VAR>xn</VAR>, <VAR>yn</VAR>)</I>
<DD><A NAME="IDX566"></A>
Sets and resets multiplot mode.

</P>
<P>
If the arguments are non-zero, <CODE>multiplot</CODE> will set up multiplot
mode with <VAR>xn</VAR>, <VAR>yn</VAR> subplots along the <VAR>x</VAR> and <VAR>y</VAR>
axes.  If both arguments are zero, <CODE>multiplot</CODE> closes multiplot
mode.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>oneplot</B> <I>()</I>
<DD><A NAME="IDX567"></A>
If in multiplot mode, switches to single plot mode.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>plot_border</B> <I>(...)</I>
<DD><A NAME="IDX568"></A>
Multiple arguments allowed to specify the sides on which the border
is shown.  Allowed arguments include:

</P>
<DL COMPACT>

<DT><CODE>"blank"</CODE>
<DD>
No borders displayed.

<DT><CODE>"all"</CODE>
<DD>
All borders displayed

<DT><CODE>"north"</CODE>
<DD>
North Border

<DT><CODE>"south"</CODE>
<DD>
South Border

<DT><CODE>"east"</CODE>
<DD>
East Border

<DT><CODE>"west"</CODE>
<DD>
West Border
</DL>

<P>
The arguments may be abbreviated to single characters.  Without any
arguments, <CODE>plot_border</CODE> turns borders off.
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>subplot</B> <I>(<VAR>rows</VAR>, <VAR>cols</VAR>, <VAR>index</VAR>)</I>
<DD><A NAME="IDX569"></A>
<DT><U>Function File:</U>  <B>subplot</B> <I>(<VAR>rcn</VAR>)</I>
<DD><A NAME="IDX570"></A>
Sets <CODE>gnuplot</CODE> in multiplot mode and plots in location
given by index (there are <VAR>cols</VAR> by <VAR>rows</VAR> subwindows).

</P>
<P>
Input:

</P>
<DL COMPACT>

<DT><VAR>rows</VAR>
<DD>
Number of rows in subplot grid.

<DT><VAR>columns</VAR>
<DD>
Number of columns in subplot grid.

<DT><VAR>index</VAR>
<DD>
Index of subplot where to make the next plot.
</DL>

<P>
If only one argument is supplied, then it must be a three digit value
specifying the location in digits 1 (rows) and 2 (columns) and the plot
index in digit 3.

</P>
<P>
The plot index runs row-wise.  First all the columns in a row are filled
and then the next row is filled.

</P>
<P>
For example, a plot with 4 by 2 grid will have plot indices running as
follows:

<PRE>
+-----+-----+-----+-----+
|  1  |  2  |  3  |  4  |
+-----+-----+-----+-----+
|  5  |  6  |  7  |  8  |
+-----+-----+-----+-----+
</PRE>

</DL>

<P>
<DL>
<DT><U>Function File:</U>  <B>subwindow</B> <I>(<VAR>xn</VAR>, <VAR>yn</VAR>)</I>
<DD><A NAME="IDX571"></A>
Sets the subwindow position in multiplot mode for the next plot.  The
multiplot mode has to be previously initialized using the
<CODE>multiplot</CODE> function, otherwise this command just becomes an alias
to <CODE>multiplot</CODE>
</DL>

</P>
<P>
<DL>
<DT><U>Function File:</U>  <B>top_title</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX572"></A>
<DT><U>Function File:</U>  <B>bottom_title</B> <I>(<VAR>string</VAR>)</I>
<DD><A NAME="IDX573"></A>
Makes a title with text <VAR>string</VAR> at the top (bottom) of the plot.
</DL>

</P>
<P><HR><P>
Go to the <A HREF="octave_1.html">first</A>, <A HREF="octave_14.html">previous</A>, <A HREF="octave_16.html">next</A>, <A HREF="octave_40.html">last</A> section, <A HREF="octave_toc.html">table of contents</A>.
</BODY>
</HTML>