This guide describes how to install the gnuplot TikZ terminal in a Windows environment. This gnuplot terminal provides a bridge from gnuplot to TikZ, allowing for the preparation of complex mathematical figures or graphs, along with consistency of caption font typesetting and line widths.
I was interested in pursuing this union of gnuplot and TikZ because gnuplot can provide the complicated, powerful graphical rendering, and TikZ can provide the consistent typesetting and parametrized styling.
Ironically, the thumbnails of the attached images demonstrate why such a process is important. Because the thumbnails auto-resize a raster image, things like font size and line thicknesses change. But view the images at 100% and you will see that this system prevents such a nuisance when attached to LaTeX documents or presentations.
For a better example, check out scaling demo - May 9, 2009 (pdf).
If you are wondering what that all means, check out http://www.texample.net/tikz/examples/gnuplot-tikz-terminal/ and http://peter.affenbande.org/gnuplot/ for starters.
#define GNUPLOT_LUA_DIR X11_DRIVER_DIR
#define GNUPLOT_LUA_DIR "c:\\Apps\\gnuplot_lua_terminal"where the path is based on TIKZ_PATH. Note the use of double \\ so the path name is that of DOS-based directory structure, and it is not munged up by the use of the unix-based escape character.
extern const char lua_ident[];make it so it reads
/* extern const char lua_ident[];*/
lua_pushstring(L, lua_ident); lua_setfield(L, luaterm, "lua_ident");and make it so it reads
/* lua_pushstring(L, lua_ident); lua_setfield(L, luaterm, "lua_ident");*/
#include "lua.trm"
TERMLIBS =It should be around line 153.
CFLAGS += -I/c/Apps/Lua/5.1/include TERMLIBS = -llua51 -L/c/Apps/Lua/5.1/libwhere the path depends on where you put Lua
DESTDIR = /c/Progra~1/Gnuplot4.2It should be around line 87
cp wgnuplot.hlp $(DESTDIR)/wgnuplot.hlpThis should be around line 449
"Lua version removed!",--string.match(term.lua_ident, "Lua [0-9\.]+"),
make -C src -f makefile.mgwThere should hopefully be no compile errors. If there are, undo the compile (described later) and try to resolve the issue
make -C src -f makefile.mgw installThis will copy all relevant files over to the installation folder defined in makefile.mgw
set term lua createstyleThis will generate the file gnuplot-lua-tikz.sty in the current directory. This is required to compile the LaTeX document. This needs only be done once, and this .sty file should be moved into whatever project uses these figures.
set term lua fulldoc set output "test.tex" plot (x**3) set output
If you made a mistake and need to recompile, navigate to the GNUPLOT_PATH and enter the following in the MinGW command prompt:
make -C src -f makefile.mgw clean
If you have any more concerns, contact me and I can try to post solutions here.
I find it helpful to make the following gnuplot file. I call it tikz-output.plt.
#this outputs a self-contained latex document. remove fulldoc to only output the tikzpicture object unset multiplot set terminal lua fulldoc
Load this in gnuplot, then set the output filename by entering the following into the gnuplot console:
set output "filename.tex"
Once this is done, load the gnuplot project you are working on, or do whatever you plan to do. Finally, close the output file with
unset multiplot set output
Note that you need to enter the unset multiplot line only if you were doing multiplot in the gnuplot project. It may be wise to just stick this at the end of your gnuplot project file to streamline things.
This will write out a TikZ style file, fully standalone, to the current gnuplot working directory. Take it from there in your favorite LaTeX editor to tweak up to your liking!
This document is a quick-and-dirty job, and leaves lots of room for improvement, documentation, and development. This is based on my experiences trying to get the system working. Based on feedback, I will improve upon this.
I am deeply grateful to my brother, Travis, for guiding me through this perilous installation process. I would not have been able to get this working without his support and patience.
Of course, I'm also very grateful for all the people who make all this open source software. LEd, MikTeX, PGF/LaTeX, gnuplot, gnuplot TikZ terminal, msys, MinGW, and so on.