Changes

Jump to navigation Jump to search
3,805 bytes added ,  04:13, 15 January 2006
reflects the recent changes in the gnuplot module
[http://www.gnuplot.info Gnuplot] is a portable command-line driven utility for function plotting for many platforms.
== Preliminary Modules ==[[source:m-gnuplot.tex|m-gnuplot.tex]]: the source file ''(contextgarden is not updated to the latest version yet, so you may not be able to see this)''
Some preliminary modules were contributed by After Peter Münster posted the first module for gnuplut support on the mailing list [http://article.gmane.org/gmane.comp.tex.context/24884] and (which only works with bash), Hans Hagen (see [http://article.gmane.org/gmane.comp.tex.context/24935] [http://article.gmane.org/gmane.comp.tex.context/24965] on the mailing list to enable inclusion ) wrote another one and Taco additionally provided some bugfixes and minor changes. The module is now a part of gnuplot graphs from ConTeXt. Follow the links mentioned above to see official distribution, but may undergo some other minor changes in the detailsshort term (use with care for some time). General idea is to enable gnuplot graphics inclusion with simple commands such as:
== Terminals ==
 
Gnuplot support output in different formats with, for example
set terminal mp color solid
will output a metapost document with colors and without dashed lines. After some appropriate preprocessing (with [[MPtoDF]] for this particular case) this file can be included in PDF documents.
 
You can specify the terminal with
<texcode>
\setupGNUPLOT[output=mp,options=color solid]
</texcode>
 
* <code>output=</code> is mandatory since that't the only way to tell ConTeXt how to preprocess the file.
* <code>options=</code> is optional and is appended to the end of <code>set terminal [terminal name]</code>. You can also override it by saying
<texcode>
% general settings for the whole document
\startGNUPLOTinclusions
set terminal postscript eps mp colorset title 'Trigonometry'solid
\stopGNUPLOTinclusions
</texcode>
But you have to be careful that you don't set any other terminal with <code>output=</code> then.
 
<!-- Another way to specify it is to override the terminal setting -->
 
Currently supported terminals are:
* [http://www.gnuplot.info/docs/gnuplot.html#mp mp/metapost]: <b>most beautiful results</b>, uses [[MPtoPDF]] to convert images to pdf
* [http://www.gnuplot.info/docs/gnuplot.html#postscript_ ps/postscript]: uses newpstopdf to convert images to pdf; ''currently some problems with rotated images unless <code>option=eps</code> is used''
* [http://www.gnuplot.info/docs/gnuplot.html#png_(OLD) png]: outputs bitmap images (no preprocessing needed)
* [http://www.gnuplot.info/docs/gnuplot.html#pdf pdf]: outputs PDF directly (no preprocessing needed), but is usually not available in most binaries of gnuplot
 
Multiple plots (more images/pages of output) are not supported (there's probably no reason to) since you can split the graphs in subsequent <code>\startGNUPLOTgraphic ... \stopGNUPLOTgraphic if necessary</code>.
 
=== Minimal Example ===
 
<texcode>
\usemodule[gnuplot]
% creating the graphics
\startGNUPLOTgraphics{sin}
plot sin(x)
\stopGNUPLOTgraphics
% including the graphics into the document
\useGNUPLOTgraphic[sin][width=5cm]
</texcode>
=== More complex example with MetaPost === Metapost produces the plots of a relatively high quality. You can use TeX commands to format the title, label axes and legend. <texcode>\usemodule[gnuplot] % output may be "mp/metapost", "ps/postscript", "pdf" or "png"; ps is currently the default\setupGNUPLOT[output=mp,option=color] % general settings for the whole document\startGNUPLOTinclusions  # you may use TeX commands to format the titles and axes set title '\bf Trigonometry'Note set xlabel '$x$' set ylabel '$y$'  # to prevent uneven numbering: Peterwill result in # (0.0, 0.5, 1.0, 1.5, ...) instead of # (0, 0.5, 1, 1.5, ...) set format yaxis '\%.1f'\stopGNUPLOTinclusions \startGNUPLOTgraphics{tan} plot tan(x) t '$\tan(x)$'\stopGNUPLOTgraphics \startGNUPLOTgraphics{sin} plot 4*sin(x)+x t '$4\sin(x)+x$', x t '$x$' lt 3\stopGNUPLOTgraphics \useGNUPLOTgraphic[tan]\useGNUPLOTgraphic[sin][width=10cm]</texcode> There's module currently only works under one problem that you have to be careful about: [[MetaPost]] terminal uses <code>cmr</code> fonts for labels. If you have the stand-alone distributions, you either have to install them by yourself or to play with <code>set terminal mp {fontname}</code> a bit (http://www.gnuplot.info/docs/gnuplot.html#mp). === More complex example: Multiple terminals === You can use different terminals for plotting the same function. {{todo|an example, similar to the one in [[source:m-gnuplot.tex|m-gnuplot.tex]], some images to get a visual impression of the main differences in terminals}} == Requirements == You have to have Gnuplot installed (and in your PATH). On most Linux, Hans's module has problems installations this is probably already the case. On Windows you either need to put the gnuplot binary in PATH manually or to create a file <code>pgnuplot.bat</code> with newlines "C:\Program Files\gnuplot\wgnupl32. Hoping exe" %1 %2 %3 %4 %5 %6 %7 %8 %9and put that that will file to a <i>"visible place"</i> (has to be fixed found in PATH)For most terminals you need <b>texmfstart</b>(.exe) as well.In case you don''t have it yet, you can grab it [http://www.pragma-ade.com/context/current/cont-win.zip here]. [[write18]] has to be enabled as well.
== Alternatives for Function Plotting in ConTeXt ==
** [[source:m-graph.tex|m-graph]] Module (see [http://cm.bell-labs.com/who/hobby/cstr_164.pdf Drawing Graphs with MetaPost] by John D. Hobby)
** link to functions that Hans wrote in MetaFun
 
{{todo|
* Fix OS-specifics to make the module work
* Support multiple terminals
* ...}}
[[Category:Modules]]
[[Category:Graphics]]
[[Category:Math]]

Navigation menu