Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 591c941c2fdf0a32dc57bb5f10791cde > files > 266

gnuplot-doc-4.4.0-5.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Iteration</TITLE>
<META NAME="description" CONTENT="Iteration">
<META NAME="keywords" CONTENT="gnuplot">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="gnuplot.css">

<LINK REL="next" HREF="node164.html">
<LINK REL="previous" HREF="node162.html">
<LINK REL="up" HREF="node113.html">
<LINK REL="next" HREF="node164.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html3419"
  HREF="node164.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html3413"
  HREF="node113.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html3407"
  HREF="node162.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html3415"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html3417"
  HREF="node467.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html3420"
  HREF="node164.html">Title</A>
<B> Up:</B> <A NAME="tex2html3414"
  HREF="node113.html">Plot</A>
<B> Previous:</B> <A NAME="tex2html3408"
  HREF="node162.html">Ranges</A>
 &nbsp; <B>  <A NAME="tex2html3416"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html3418"
  HREF="node467.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION040147000000000000000"></A>
<A NAME="commands_plot_iteration"></A><A NAME="commands_splot_iteration"></A><A NAME="plot_iteration"></A><A NAME="splot_iteration"></A><A NAME="3409"></A>
<BR>
Iteration
</H2>
If many similar files or functions are to be plotted together, it may be
convenient to do so by iterating over a shared plot command.

<P>
Syntax:
<BR>
<PRE>
     plot for [&lt;variable&gt; = &lt;start&gt; : &lt;end&gt; {:&lt;increment&gt;}]
     plot for [&lt;variable&gt; in "string of words"]
</PRE>
<BR>

<P>
The scope of an iteration ends at the next comma or the end of the
command, whichever comes first.  Iteration can not be nested.

<P>
This will plot one curve, sin(3x), because iteration ends at the comma
<BR>
<PRE>
     plot for [i=1:3] j=i, sin(j*x)
</PRE>
<BR>
This will plot three curves because there is no comma after the definition of j
<BR>
<PRE>
     plot for [i=1:3] j=i sin(j*x)
</PRE>
<BR>

<P>
Example:
<BR>
<PRE>
     plot for [dataset in "apples bananas"] dataset."dat" title dataset
</PRE>
<BR>

<P>
In this example iteration is used both to generate a file name and a
corresponding title.

<P>
Example:
<BR>
<PRE>
     file(n) = sprintf("dataset_%d.dat",n)
     splot for [i=1:10] file(i) title sprintf("dataset %d",i)
</PRE>
<BR>

<P>
This example defines a string-valued function that generates file names,
and plots ten such files together. The iteration variable ('i' in this
example) is treated as an integer, and may be used more than once.

<P>
Example:
<BR>
<PRE>
     set key left
     plot [0:1] for [n=1:4] x**n sprintf("%d",n)
</PRE>
<BR>

<P>
This example plots a family of functions.

<P>
Example:
<BR>
<PRE>
     list = "apple banana cabbage daikon eggplant"
     item(n) = word(list,n)
     plot for [i=1:words(list)] item[i].".dat" title item(i)
     list = "new stuff"
     replot
</PRE>
<BR>

<P>
This example steps through a list and plots once per item.
Because the items are retrieved dynamically, you can change the list
and then replot.

<P>
Example:
<BR>
<PRE>
     list = "apple banana cabbage daikon eggplant"
     plot for [i in list] i.".dat" title i
     list = "new stuff"
     replot
</PRE>
<BR>

<P>
This is example does exactly the same thing as the previous example, but uses
the string iterator form of the command rather than an integer iterator.

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html3419"
  HREF="node164.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html3413"
  HREF="node113.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html3407"
  HREF="node162.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html3415"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html3417"
  HREF="node467.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html3420"
  HREF="node164.html">Title</A>
<B> Up:</B> <A NAME="tex2html3414"
  HREF="node113.html">Plot</A>
<B> Previous:</B> <A NAME="tex2html3408"
  HREF="node162.html">Ranges</A>
 &nbsp; <B>  <A NAME="tex2html3416"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html3418"
  HREF="node467.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2010-08-17
</ADDRESS>
</BODY>
</HTML>