Changes

Jump to navigation Jump to search
1,140 bytes added ,  19:24, 8 June 2020
m
no edit summary
[http://www.gnuplot.info Gnuplot] is a portable command-line driven utility for function plotting for many platforms.
To make the examples on this page work, you need a modified binary of Gnuplot 4.6.0 or later (see belowor self-compiled binary).
== Minimal Example ==
== Requirements ==
* '''[http://modules.contextgarden.net/gnuplot Gnuplot module]''' (on MikTeX ** in TeX Live you need to have <code>context-gnuplot</code> installed, in [[ConTeXt Standalone]] you can install it's part of the distribution already)with <code>--modules=t-gnuplot</code> switch
* '''Gnuplot has to be installed''' (and in your PATH)
:On most Linux installations this is probably already the case. On Windows gnuplot.exe is usually also shipped and you have need to make sure that it is in PATH. In case that the binary has a different name, you could create a file <code>gnuplot.bat</code> with something like:
"C:\Program Files\gnuplot\bin\wgnupl32.exe" %*
:(if that was the binary name) and put that file to a <i>"visible place"</i> (has to be found in PATH).Please note: if calling <code>gnuplot</code> from cmd works for you, there is no need to do anything extra.* '''[[Write18]]''' has to be enabled
=== To use the ConTeXt terminal (recommended) ===
* for ==== Windows, you ====You can take fetch binaries from [http://dl.contextgardensourceforge.net/modulesprojects/gnuplot-win.zip these] binaries from [[modules:/files/gnuplot-win|Modules in the garden]/ sourceforge (released versions)]* for Linux or Mac you have to download the source from [http://www.gnuplottatsuromatsuoka.info (use [http:com/gnuplot/downloads.sourceforge.netEng/gnuplotwinbin/gnuplot-Tatsuro Matsuoka (latest cvs version)].==== Unix or Mac ====The easiest way is to use version 4.26.0or later shipped by your distribution.tarIf that version is too old, you need to compile your own.gz this file]), extract it, copy [http If you want to use the version from trunk: # unofficial; you can also use official cvs git clone git://dlgithub.contextgarden.net/modulescom/gnuplot-win/gnuplot/term/context.trm context.trm] to <code>term/</code>, add <code>#include "context.trm"</code> to <code>src/term.h</code> and compile it usinggit
./prepare
./configure
make
* '''[ make installI use <code>./configure --prefix=$PWD/inst</code> to avoid cluttering the system and install gnuplot to my personal directory. You can use other flags to configure for a different choice of GUI terminals. If you want to use the released version, get it from [write18http://sourceforge.net/projects/gnuplot/files/gnuplot/ sourceforge]]''' has to be enabledand do the same, just skip the <code>./prepare</code>. The latest version of context terminal is available at http://github.com/mojca/gnuplot/raw/master/term/context.trm. Feel free to contact me [[User:Mojca Miklavec|Mojca]] in case of problems.
== Creating stand-alone, whole-page plots ==
Here's an example of how to make a stand-alone ConTeXt document with one plot per page:
set term context standalone size 15cm,10cm header '\usetypescript[iwona][ec]' font 'iwona,ss' 10dd
set output 'example.tex'
plot ...
== More complex example ==
 
(I need to change this example to highlight other aspects. Metapost is kind-of-obsolete since ConTeXt terminal was derived from it and produces superior results. But the example below should still be valid.)
<texcode>
\usemodule[gnuplot]
\setupGNUPLOT[terminal=mptikz,option=color]% terminal=mp if you only have an old gnuplot at hand
% general settings for the whole document
# (0.0, 0.5, 1.0, 1.5, ...) instead of
# (0, 0.5, 1, 1.5, ...)
set format y '\%.1f'
\stopGNUPLOTinclusions
<!-- Another way to specify it is to override the terminal setting -->
Currently supported terminals are(attention: links not from the latest documentation):
* [http://www.gnuplot.info/docs/gnuplot.html#mp mp/metapost]: uses [[MPtoPDF]] to convert images to pdf, but the context terminal should replace it
* [http://www.gnuplot.info/docs/gnuplot.html#postscript_ ps/postscript]: most advanced in the number of supported features
* [http://www.gnuplot.info/docsdocs_4.0/gnuplot.html#png_%28NEW%29 png (OLD1) ],[http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-41500051.53 png(2)]: outputs bitmap images (no preprocessing needed)* [http://www.gnuplot.info/docsdocs_4.0/gnuplot.html#pdf pdf(old)],[http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-41300051.51 pdf (new)]: outputs PDF directly for (no preprocessing needed), but is usually not available in most binaries of gnuplot
* '''context''':
== Development == * The current gnuplot-documentation can be downloaded [http://renojrlwww.lrvgnuplot.uvsqinfo/docs_4.fr6/darcswebgnuplot.cgi?r=gpConTeXt;a=summary darcs repositorypdf here] (maintained by Renaud Aubin; currently I'm unable to login, so it's not up to date)* [http://groups.google.com/group/gnuplot-context mailing list]
== History ==
I'm currently sticking tiny pieces together in the way I want the module to work. Hans could probably finish the same work that costs me a few days in a few minutes, but after dropping me a bone, he decided to leave me the joy of diving into ConTeXt internals and to let me figure out how to program in ConTeXt by myself. So I still keep spamming the mailing list with numerous questions and both Taco and Hans - without whom implementing the module would be impossible - keep answering.
 
== Old wiki pages ==
* 2006 - [[Gnuplot Development]]
 
== Alternatives for Function Plotting ==
* in [[MetaPost]]
** [[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)
** functions in [[MetaFun - MetaPost in ConTeXt|MetaFun]], see [[manual:metafun-s.pdf|metafun-s.pdf]], section 9.3
* others
** [http://pyx.sourceforge.net/ PyX] - graph drawing through python interface with TeX typesetting & PostScript capabilities
** [http://comp.uark.edu/~luecking/tex/mfpic.html mfpic] - a scheme for producing pictures from LaTeX commands. The LaTeX commands generate a input file to be processed by Metapost.
** [http://matplotlib.sourceforge.net matplotlib] - a Matlab-inspired Python based plotting tool which incorporates many features, including the use of TeX in labels, titles etc.
** [http://tug.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/ pgfplots] - a TikZ-based LaTeX package for drawing graphs
=== Other links ===
* [http://tug.ctan.org/tex-archive/macros/latex/contrib/exceltex/ exceltex] - an interesting LaTeX package to get data from Excel into LaTeX
[[Image:Slo Ministry of Higher Education Science and Technology.jpg]]
[[Category:Modules]]
[[Category:Graphics]]
[[Category:MathSciences]]

Navigation menu