%META:TOPICINFO{author="TWikiContributor" date="1300004217" format="1.1" version="$Rev$"}%
---+!! <nop>%TOPIC% 
<!--
   Contributions to this plugin are appreciated. Please update the plugin page at
   http://twiki.org/cgi-bin/view/Plugins/GnuPlotPlugin or provide feedback at
   http://twiki.org/cgi-bin/view/Plugins/GnuPlotPluginDev.
   If you are a TWiki contributor please update the plugin in the SVN repository.
-->
<sticky><div style="float:right; background-color:#EBEEF0; margin:0 0 20px 20px; padding: 0 10px 0 10px;">
%TOC{title="Page contents"}%
</div></sticky>
%SHORTDESCRIPTION%

---++ Syntax Rules

   * Just add =%<nop>GNUPLOT{"PlotName"}%= anywhere in the page where you want the plot to appear and save the topic
   * Multiple plots can be displayed within one topic
   * Any CSV (Comma Seperated Variable) file attached to the topic can be used with the plot or splot commands

---++ Examples 

The following images are examples of plots generated by !GnuPlot:

---+++ Simple function test 
   
<style type="text/css">
.gnuPlot table { border-bottom: 1px dotted grey; border-left: 1px dotted grey }
.gnuPlot td { padding: 11px 20px 20px 11px; border-top: 1px dotted grey; border-right: 1px dotted grey }
</style>

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>TestInstall):<br />
<img src="%ATTACHURLPATH%/TestInstallSample.png" alt="TestInstallSample.png" width='639' height='517' />
</td>
<td>
Plugin (<nop>TestInstall):<br />
%GNUPLOT{"TestInstall"}%
</td>
<td>
Verbatim (<nop>TestInstall):<br />
<verbatim>
%GNUPLOT{"TestInstall"}%

Plot settings:
set title "TestInstall"
set datafile separator ","
set terminal png
plot sin(x), cos(x), x*x/10
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Multi graphs with errorbars, datafile based

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>MultigraphWithErrorbars):<br />
<img src="%ATTACHURLPATH%/MultigraphWithErrorbarsSample.png" alt="MultigraphWithErrorbarsSample.png" width='631' height='517' />
</td>
<td>
Plugin (<nop>MultigraphWithErrorbars):<br />
%GNUPLOT{"MultigraphWithErrorbars"}%
</td>
<td>
Verbatim (<nop>MultigraphWithErrorbars):<br />
<verbatim>
%GNUPLOT{"MultigraphWithErrorbars"}%

Plot settings:
set title "MultigraphWithErrorbars"
set xlabel "X Axis Label"
set ylabel "Y Axis Label"
set term gif
set data style lp
set terminal png
plot [.8:4.2] "MultigraphWithErrorbarsData.data" using 1:2 t "Curve Title", \
"MultigraphWithErrorbarsData.data" using 1:2:3:4 notitle with errorbars ps 0, \
"MultigraphWithErrorbarsData.data" using 1:5 t "Other Curve", \
"MultigraphWithErrorbarsData.data" using 1:5:6:7 notitle with errorbars ps 0
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Damped sinus, datafile based

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>DampedSinus):<br />
<img src="%ATTACHURLPATH%/DampedSinusSample.png" alt="DampedSinusSample.png" width='647' height='516' />
</td>
<td>
Plugin (<nop>DampedSinus):<br />
%GNUPLOT{"DampedSinus"}%
</td>
<td>
Verbatim (<nop>DampedSinus):<br />
<verbatim>
%GNUPLOT{"DampedSinus"}%

Plot settings:
set title "DampedSinus"
set xlabel "X Axis Label"
set ylabel "Y Axis Label"
set terminal png
plot 'DampedSinusData.data'
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Map of Denmark, datafile based!! (data from CIA World Data Bank II)

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>CIAWorldDataBankIIDenmark):<br />
<img src="%ATTACHURLPATH%/CIAWorldDataBankIIDenmarkSample.png" alt="CIAWorldDataBankIIDenmarkSample.png" width='635' height='518' />
</td>
<td>
Plugin (<nop>CIAWorldDataBankIIDenmark):<br />
%GNUPLOT{"CIAWorldDataBankIIDenmark"}%
</td>
<td>
Verbatim (<nop>CIAWorldDataBankIIDenmark):<br />
<verbatim>
%GNUPLOT{"CIAWorldDataBankIIDenmark"}%

Plot settings:
set title "CIAWorldDataBankIIDenmark"
set noxtics
set noytics
set noborder
set data style dots
set terminal png
plot "CIAWorldDataBankIIDenmarkData.data" title "" with lines 
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Interlocking Tori (3D)

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>InterlockingTori):<br />
<img src="%ATTACHURLPATH%/InterlockingToriSample.png" alt="InterlockingToriSample.png" />
</td>
<td>
Plugin (<nop>InterlockingTori):<br />
%GNUPLOT{"InterlockingTori"}%
</td>
<td>
Verbatim (<nop>InterlockingTori):<br />
<verbatim>
%GNUPLOT{"InterlockingTori"}%

Plot settings:
set parametric
set isosamples 50,10
set hidden
set title "Interlocking Tori"
set key below
set urange [-pi:pi]
set vrange [-pi:pi]
set isosamples 50,20
set terminal png
splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with lines, 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with lines
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Blue Whale (3D), datafile based

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>BlueWhale):<br />
<img src="%ATTACHURLPATH%/BlueWhaleSample.png" alt="BlueWhaleSample.png"  />
</td>
<td>
Plugin (<nop>BlueWhale):<br />
%GNUPLOT{"BlueWhale"}%
</td>
<td>
Verbatim (<nop>BlueWhale):<br />
<verbatim>
%GNUPLOT{"BlueWhale"}%

Plot settings:
set parametric
set hidden3d
set nokey
set xrange [0:8]
set yrange [-4:4]
set zrange [-2:2]
set data style line
set title "Blue Whale"
set terminal png
splot "whale.dat"
</verbatim>
</td>
</tr>
</table>
</div>

---+++ Alternative <nop>GnuPlot render sizes, Rosenbrock!! Function

This one is shown in 350x280. Try blowing it up in size - alter the =set terminal png size 350,280= line into something larger (i.e. =1000,1000=).

<div class="gnuPlot">
<table width="1700">
<tr>
<td>
Pre-rendered sample (<nop>RosenbrockFunction):<br />
<img src="%ATTACHURLPATH%/RosenbrockFunctionSample.png" alt="RosenbrockFunctionSample.png" />
</td>
<td>
Plugin (<nop>RosenbrockFunction):<br />
%GNUPLOT{"RosenbrockFunction"}%
</td>
<td>
Verbatim (<nop>RosenbrockFunction):<br />
<verbatim>
%GNUPLOT{"RosenbrockFunction"}%

Plot settings:
set logscale z 10
set view 20, 340, 1, 1
set isosamples 60, 60
set hidden3d offset 1 trianglepattern 3 undefined 1 altdiagonal bentover
set style data lines
set ticslevel 0
set title "Rosenbrock Function" 0.000000,0.000000  font ""
set xlabel "x" -5.000000,-2.000000  font ""
set xrange [ * : * ] noreverse nowriteback  # (currently [0.00000:15.0000] )
set ylabel "y" 4.000000,-1.000000  font ""
set yrange [ * : * ] noreverse nowriteback  # (currently [0.00000:15.0000] )
set zlabel "Z axis" 0.000000,0.000000  font ""
set zrange [ * : * ] noreverse nowriteback  # (currently [-1.20000:1.20000] )
set terminal png size 350,280
splot [-1.5:1.5] [-0.5:1.5] (1-x)**2 + 100*(y - x**2)**2
</verbatim>
</td>
</tr>
</table>
</div>

---++ Plugin Settings 

   * One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
      * Set SHORTDESCRIPTION = Allows users to plot data and functions using <nop>GnuPlot

   * Debug plugin: (See output in =data/debug.txt=)
      * Set DEBUG = 0

---++ Plugin Installation Instructions 

__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

   * For an __automated installation__, run the [[%SCRIPTURL{configure}%][configure]] script and follow "Find More Extensions" in the in the __Extensions__ section.

   * Or, follow these __manual installation__ steps:
      * Download the ZIP file from the Plugins home (see below).
      * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
        | *File:* | *Description:* |
        | ==data/TWiki/GnuPlotPlugin.txt== | Plugin topic |
        | ==data/TWiki/GnuPlotHelp.txt== | Help topic |
        | ==lib/TWiki/Plugins/GnuPlotPlugin.pm== | Plugin Perl module |
        | ==lib/TWiki/Plugins/GnuPlotPlugin/Plot.pm== | Perl module responsible for rendering the plot area |
        | ==lib/TWiki/Plugins/GnuPlotPlugin/PlotSettings.pm== | Perl module responsible for managing the settings |
        | ==pub/TWiki/GnuPlotHelp/gnuplot.html==| HTML file |
        | ==pub/TWiki/GnuPlotPlugin/*==| Sample plot data files |
        | ==tools/gnuplot.pl==| Helper Perl script |
      * Set the ownership of the extracted directories and files to the webserver user.

   * Plugin __configuration and testing__:
      * Run the [[%SCRIPTURL{configure}%][configure]] script and enable the plugin in the __Plugins__ section.
      * In =lib/TWiki/Plugins/GnuPlotPlugin/Plot.pm= look for the following line and update the paths to fit your environment: %BR%
        =# Update $gnuplotPath, $gnuplotHelperPath and $execCmd to fit your environment=
      * Test if the installation was successful: See examples above
      
---++ Planned improvements

   * TWiki compatible syntax for using datafiles from any topic.
   * Form based editing of plot settings to make it easier for users that are not familiar with [[GnuPlotHelp][GnuPlot]]

---++ Plugin Info 

|  Plugin Author: | TWiki:Main.AbieSwanepoel |
|  Copyright: | &copy; 2006 TWiki:Main.AbieSwanepoel <br /> &copy; 2008-2011 TWiki:TWiki.TWikiContributor |
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
|  Plugin Version: | 2011-03-12 |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
|  2011-03-12: | TWikibug:Item6638: Fix code for TWiki-4.0 and up; doc fixes; changing TWIKIWEB to SYSTEMWEB -- TWiki:Main.PeterThoeny |
|  2006-04-30: | Added sandbox security mechanism -- TWiki:Main.SteffenPoulsen |
|  2006-04-19: | Fixed anchors, added 3D examples, added png size option -- TWiki:Main.SteffenPoulsen |
|  2006-04-17: | Doc update, changed working dir to ATTACHURLPATH -- TWiki:Main.SteffenPoulsen |
|  2006-01-27: | Initial version |
|  TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
|  CPAN Dependencies: | none |
|  Other Dependencies: | !GnuPlot (available from http://www.gnuplot.info) with support for a PNG terminal |
|  Perl Version: | 5.005 |
|  [[TWiki:Plugins/Benchmark][Benchmarks]]: | %SYSTEMWEB%.GoodStyle 100%, %SYSTEMWEB%.FormattedSearch 100%, %TOPIC% 100% |
|  Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ GnuPlotHelp, %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiPlugins

%META:FILEATTACHMENT{name="DampedSinusSample.png" attr="h" comment="Pre-rendered graphics for <nop>DampedSinusSample example" date="1146425499" path="DampedSinusSample.png" size="9541" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="DampedSinusData.data" attr="h" comment="Data for <nop>DampedSinusData example" date="1146425499" path="DampedSinusData.data" size="4091" user="WikiContributor" version="1"}%
%META:FILEATTACHMENT{name="MultigraphWithErrorbarsData.data" attr="h" comment="Data for <nop>MultigraphWithErrorbarsData example" date="1146425499" path="MultigraphWithErrorbarsData.data" size="66" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="MultigraphWithErrorbars.png" attr="h" comment="" date="1146425781" path="MultigraphWithErrorbars.png" size="4919" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="InterlockingTori.gnu" attr="h" comment="" date="1146425499" path="InterlockingTori.gnu" size="324" user="UnknownUser" version="1"}%
%META:FILEATTACHMENT{name="RosenbrockFunction.err" attr="h" comment="" date="1146425782" path="RosenbrockFunction.err" size="0" user="UnknownUser" version="1"}%
%META:FILEATTACHMENT{name="MultigraphWithErrorbars.err" attr="h" comment="" date="1146425781" path="MultigraphWithErrorbars.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="TestInstall.gnu" attr="h" comment="" date="1146425499" path="TestInstall.gnu" size="100" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="InterlockingTori.png" attr="h" comment="Pre-rendered graphics for <nop>InterlockingTori example" date="1146425782" path="InterlockingTori.png" size="8858" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="CIAWorldDataBankIIDenmark.png" attr="h" comment="" date="1146425781" path="CIAWorldDataBankIIDenmark.png" size="8657" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="TestInstallSample.png" attr="h" comment="Pre-rendered graphics for <nop>TestInstallSample example" date="1146425499" path="TestInstallSample.png" size="9309" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="MultigraphWithErrorbars.gnu" attr="h" comment="" date="1146425499" path="MultigraphWithErrorbars.gnu" size="434" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="DampedSinus.err" attr="h" comment="" date="1146425781" path="DampedSinus.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="BlueWhaleSample.png" attr="h" comment="" date="1146425499" path="BlueWhaleSample.png" size="9633" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="MultigraphWithErrorbarsSample.png" attr="h" comment="Pre-rendered graphics for <nop>MultigraphWithErrorbarsSample example" date="1146425499" path="MultigraphWithErrorbarsSample.png" size="9082" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="BlueWhale.png" attr="h" comment="Pre-rendered graphics for <nop>BlueWhale example" date="1146425782" path="BlueWhale.png" size="4610" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="InterlockingToriSample.png" attr="h" comment="" date="1146425499" path="InterlockingToriSample.png" size="15800" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="RosenbrockFunction.png" attr="h" comment="Pre-rendered graphics for <nop>RosenbrockFunction example" date="1146425784" path="RosenbrockFunction.png" size="5130" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="DampedSinus.gnu" attr="h" comment="" date="1146425499" path="DampedSinus.gnu" size="126" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="BlueWhale.gnu" attr="h" comment="" date="1146425499" path="BlueWhale.gnu" size="179" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="BlueWhale.err" attr="h" comment="" date="1146425782" path="BlueWhale.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="CIAWorldDataBankIIDenmarkData.data" attr="h" comment="Data for <nop>CIAWorldDataBankIIDenmark example" date="1146425499" path="CIAWorldDataBankIIDenmarkData.data" size="403115" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="TestInstall.png" attr="h" comment="" date="1146425781" path="TestInstall.png" size="5060" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="CIAWorldDataBankIIDenmarkSample.png" attr="h" comment="Pre-rendered graphics for <nop>CIAWorldDataBankIIDenmark example" date="1146425499" path="CIAWorldDataBankIIDenmarkSample.png" size="15279" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="DampedSinus.png" attr="h" comment="" date="1146425781" path="DampedSinus.png" size="4659" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="CIAWorldDataBankIIDenmark.gnu" attr="h" comment="" date="1146425499" path="CIAWorldDataBankIIDenmark.gnu" size="182" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="CIAWorldDataBankIIDenmark.err" attr="h" comment="" date="1146425781" path="CIAWorldDataBankIIDenmark.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="whale.dat" attr="h" comment="" date="1146425499" path="whale.dat" size="94590" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="RosenbrockFunction.gnu" attr="h" comment="" date="1146425499" path="RosenbrockFunction.gnu" size="700" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="InterlockingTori.err" attr="h" comment="" date="1146425781" path="InterlockingTori.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="TestInstall.err" attr="h" comment="" date="1146425781" path="TestInstall.err" size="0" user="TWikiContributor" version="1"}%
%META:FILEATTACHMENT{name="RosenbrockFunctionSample.png" attr="h" comment="" date="1146425499" path="RosenbrockFunctionSample.png" size="9867" user="TWikiContributor" version="1"}%
