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.  Document fonts and LaTeX math do not matter

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.

3.  Document fonts and/or LaTeX math do matter

3.1  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-gnuplot-tex.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 files, 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.

3.2  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-gnuplot-tex.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.

4.  Categories

Category: Tip Gnuplot External Material

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2024-06-09 15:24 UTC