Changes

Jump to navigation Jump to search
1,299 bytes added ,  23:58, 13 July 2020
lmtx example for gnuplot inclusion
[http://www.gnuplot.info Gnuplot] is a portable command-line driven utility for function plotting for many platforms.
All To make the examples on this page talk about how the things are supposed to work once the new terminal is uploaded, you need Gnuplot 4.6. The code described doesn't work yet unless you download new files from the darcs repository 0 or later (see belowor self-compiled binary).}}
== Minimal Example ==
% write a script for gnuplot
\startGNUPLOTscript{[sin}]
plot sin(x)
\stopGNUPLOTscript
== Requirements ==
* '''recent version of ConTeXt''' and '''texmfstart''' in your PATH* '''[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 want , there is no need to use the ConTeXt terminal (default), do anything extra.* '''you need modified binaries[[Write18]]''' until they officially become part of gnuplothas to be enabled** if you want to try it on Linux, you have to download === To use the source ConTeXt terminal (recommended) ======= Windows ====You can fetch binaries from [http://wwwsourceforge.net/projects/gnuplot/files/gnuplot.info, add / sourceforge (released versions)] or from [http://renojrlwww.lrvtatsuromatsuoka.uvsq.frcom/projectsgnuplot/gpcontextEng/termwinbin/context.trm context.trmTatsuro Matsuoka (latest cvs version)], fix the file <code>term.h</code> and compile it.** For windows version of binary ==== Unix or if you have problems compiling it, please mail me Mac ====The easiest way is to <mojcause version 4.miklavec6.lists(at)gmail0 or later shipped by your distribution.com>* '''[[write18]]''' has If that version is too old, you need to be enabledcompile your own.
If you want to use the version from trunk: # unofficial; you can also use official cvs git clone git://github.com/gnuplot/gnuplot.git ./prepare ./configure make make installI use <icode>The module has some strange problems when used on MikTeX (memory limit exceeded or something similar). I'll try to figure out what exactly is going on./configure --prefix=$PWD/inst</icode> --[[User:Mojca Miklavec|Mojca]]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.
== Terminals ==If you want to use the released version, get it from [http://sourceforge.net/projects/gnuplot/files/gnuplot/ sourceforge] and do the same, just skip the <code>./prepare</code>.
Gnuplot support output in different formats with, for example set The latest version of context terminal mp color solidwill output a metapost document with colors and without dashed linesis available at http://github. After some appropriate preprocessing (with [[MPtoDF]] for this particular case) this file can be included in PDF documentscom/mojca/gnuplot/raw/master/term/context.trm.
You can specify the terminal with<texcode>\setupGNUPLOTFeel free to contact [terminal=mp,options=color solid[User:Mojca Miklavec|Mojca]]</texcode>in case of problems.
* <code>terminal=</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>\startGNUPLOTinclusionsset terminal mp color solid\stopGNUPLOTinclusions</texcode>But you have to be careful that you don't set any other terminal with <code>output=</code> then. <!Creating stand-alone, whole- Another way to specify it is to override the terminal setting -->page plots ==
Currently supported terminals are:* [http://www.gnuplot.info/docs/gnuplot.html#mp mp/metapost]: <b>most beautiful results</b>, uses [[MPtoPDF]] to convert images Here's an example of how 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/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* '''context'''make a stand-alone ConTeXt document with one plot per page: new
=== More complex set term context standalone size 15cm,10cm header '\usetypescript[iwona]' font 'iwona,ss' 10dd set output 'example with MetaPost or ConTeXt terminal ===.tex' plot ...
Metapost produces the plots of a relatively high quality. You can use TeX commands to format the title, label axes and legend.== More complex example ==
<texcode>
\usemodule[gnuplot]
% output may be "mp/metapost", "ps/postscript", "pdf" or "png"; ps is currently the default\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
\startGNUPLOTscript{[tan}]
plot tan(x) t '$\tan(x)$'
\stopGNUPLOTscript
\startGNUPLOTscript{[sin}]
plot 4*sin(x)+x t '$4\sin(x)+x$', x t '$x$' lt 3
\stopGNUPLOTscript
</texcode>
There's only one problem that you have to be careful about: == Example with externalfigure == In [[MetaPostLMTX]] terminal uses <code>cmr</code> fonts we can use externalfigure for labelsgnuplot files like this: m-gnuplot-demo. If you have the stand-alone distributions, you either have to install them by yourself or to play with gp<codetexcode>set terminal mp {fontname}</code> format xy "$%g$" set title 'This is a bit plot of $y=\\sin(httpx)$'set xlabel 'This is the $x$ axis'set ylabel 'This is the $y$ axis' plot [0:6.28] [0:1] sin(x)<//wwwtexcode> Then including it in the .tex file with externalfigure and svg conversion: <texcode>\usemodule[gnuplot] \starttext\externalfigure[m-gnuplot-demo.infogp][conversion=svg,width=4cm]\stoptext</docs/gnuplot.html#mp).texcode> == Using other terminals ==
=== More complex example: Multiple terminals ===<i>(Needs a revision.)</i>
You can use Gnuplot support output in different terminals formats with, for plotting the same functionexample set terminal mp color solidwill output a metapost document with colors and without dashed lines. After some appropriate preprocessing (with [[MPtoPDF]] for this particular case) this file can be included in PDF documents.
{{todo|an example, similar to You can specify the one in terminal with<texcode>\setupGNUPLOT[[source:m-gnuplot.tex|m-gnuplot.tex]terminal=mp,options=color solid], some images to get a visual impression of the main differences in terminals}}</texcode>
* <code>terminal=</code> is mandatory since that't the only way to tell ConTeXt how to preprocess the file.* <code>options= Development =</code> is optional and is appended to the end of <code>set terminal [terminal name]</code>. You can also override it by saying<texcode>\startGNUPLOTinclusionsset terminal mp color 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 (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/docs_4.0/gnuplot.html#png_%28NEW%29 png (1)],[http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-41500051.53 png (2)]: outputs bitmap images (no preprocessing needed)* [http://www.gnuplot.info/docs_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''':
* 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)* [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://theory.kitp.ucsb.edu/~paxton/tioga.html Tioga] - creating figures and plots using Ruby, PDF, and TeX
** [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]]
174

edits

Navigation menu