changeset 23214:76a894168fe5 stable

doc: provide complete examples in plotting documentation (bug #44263) * doc/interpreter/plot.txi: The plotting example codes were given in a truncated form. To be honest with the users, the full examples are provieded without being too verbose.
author Michael D. Godfrey <michaeldgodfrey@gmail.com>
date Tue, 21 Feb 2017 14:55:34 +0100
parents b8a186a9760b
children 0842b119dc1b
files doc/interpreter/plot.txi
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/plot.txi	Mon Feb 20 18:11:02 2017 +0100
+++ b/doc/interpreter/plot.txi	Tue Feb 21 14:55:34 2017 +0100
@@ -89,6 +89,9 @@
 @group
 x = -10:0.1:10;
 plot (x, sin (x));
+xlabel ("x");
+ylabel ("sin (x)");
+title ("Simple 2-D Plot");
 @end group
 @end example
 
@@ -123,13 +126,19 @@
 
 @example
 @group
+randn ("state", 1);
 hist (randn (10000, 1), 30);
+xlabel ("Value");
+ylabel ("Count");
+title ("Histogram of 10,000 normally distributed random numbers");
 @end group
 @end example
 
 @noindent
 produces the histogram of 10,000 normally distributed random numbers
-shown in @ref{fig:hist}.
+shown in @ref{fig:hist}.  Note that, @code{randn ("state", 1);} sets
+the start value for @code{randn} so that the returned values are
+always the same as shown.
 
 @float Figure,fig:hist
 @center @image{hist,4in}
@@ -177,11 +186,16 @@
 
 @example
 @group
+rand ("state", 2);
 x = 0:0.1:10;
 y = sin (x);
 lerr = 0.1 .* rand (size (x));
 uerr = 0.1 .* rand (size (x));
 errorbar (x, y, lerr, uerr);
+axis ([0, 10, -1.1, 1.1]);
+xlabel ("x");
+ylabel ("sin (x)");
+title ("Errorbar plot of sin (x)");
 @end group
 @end example
 
@@ -207,6 +221,7 @@
 
 @example
 polar (0:0.1:10*pi, 0:0.1:10*pi);
+title ("Example polar plot from 0 to 10*pi");
 @end example
 
 @noindent
@@ -318,6 +333,10 @@
 r = sqrt (xx .^ 2 + yy .^ 2) + eps;
 tz = sin (r) ./ r;
 mesh (tx, ty, tz);
+xlabel ("tx");
+ylabel ("ty");
+zlabel ("tz");
+title ("3-D Sombrero plot");
 @end group
 @end example
 
@@ -343,7 +362,11 @@
 t = 0:0.1:10*pi;
 r = linspace (0, 1, numel (t));
 z = linspace (0, 1, numel (t));
-plot3 (r.*sin(t), r.*cos(t), z);
+plot3 (r.*sin (t), r.*cos (t), z);
+xlabel ("r.*sin (t)");
+ylabel ("r.*cos (t)");
+zlabel ("z");
+title ("plot3 display of 3-D helix");
 @end group
 @end example