Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

UsingLyXWithGnuplot

<< | Page list | >>

This tip shows how to integrate gnuplot diagrams into your LyX document efficiently.

1.  Example to start with (including first aid)

In LyX 2.4, go to File > Open Example and choose External Material > Gnuplot.

2.  Different methods of gnuplot inclusion

Text files with gnuplot commands can be included either

  • without further processing of fonts and LaTeX math expressions or scientific formula. That is, the fonts in the gnuplot are not necessarily the fonts of the document, and math expressions and scientific formula output by LaTeX are not required in the gnuplot. Or
  • with further processing of fonts and LaTeX math expressions or scientific formula. That is, the fonts in the gnuplot are typeset and consistent with document fonts, and LaTeX math expressions and scientific formula in the gnuplot appear with proper LaTeX output.

2.1  Gnuplot inclusion without further processing of fonts and LaTeX math expressions

Save your gnuplot commands in a textfile with extension .gp as in my-gnuplot.gp. In LyX, go to Insert > Image and point to my-gnuplot.gp by means of the image dialog. You will be asked to authorize the conversion of the gnuplot command file into an image.

2.2  Gnuplot inclusion with further processing of fonts and LaTeX math expressions

With the gnuplot terminal cairolatex

Start your gnuplot commands in your textfile my-tex-gnuplot.gp with the lines

set term cairolatex pdf or set term cairolatex eps

set output my-tex-gnuplot.tex

This produces a PDF or EPS containing the graph together with a file my-tex-gnuplot.tex with e. g. labels, legends, math or scientific expressions to be typeset by LaTeX.

In LyX, go to Insert > File > Child document, point to my-tex-gnuplot.tex bei means of the dialog and choose "Input" as mode of inclusion. You can get a preview by selecting the file inclusion in the LyX document, proceed to Insert > Embedded preview and click on that menu item.

Frequent LyX-gnuplot users can let LyX do these steps conveniently by calling my-gnuplot.gp as external material. Installation of the required gnuplot.xtemplate, converter scripts, configuration of LyX and usage can be found here https://wiki.lyx.org/Tools/GnuplotInLyX.

If you configure LyX to open files with the extension .gp with a text editor, then you can right click on your gnuplot in LyX and edit the gnuplot command file my-gnuplot.gp directly. To this end, go to Tools > Settings > Formats > Gnuplot and choose as application to edit "User defined" and your favourite text editor.

With the gnuplot terminal tikz

Make the TeX files of the gnuplot package, e. g. gnuplot-lua-tikz.sty, known to your TeX-Installation and then to LyX. In LyX, go to Document > Settings > Preamble, put the line \usepackage{gnuplot-lua-tikz} in it, apply and save.

Start your gnuplot commands in your textfile my-tex-gnuplot.gp with the lines

set term tikz

set output my-tex-gnuplot.tex

This produces a file my-tex-gnuplot.tex with e. g. labels, legends, math or scientific expressions to be typeset by LaTeX.

In LyX, go to Insert > File > Child document, point to my-tex-gnuplot.tex bei means of the dialog and choose "Input" as mode of inclusion. You can get a preview by selecting the file inclusion in the LyX document, proceed to Insert > Embedded preview and click on that menu item.

3.  Categories

Category: Tip Gnuplot External Material

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2025-07-26 16:44 UTC