4

Earlier I have used Gnuplot and created a pdf-file which I then implemented via includegraphics in my Latex-document.

Isn't there a better way to plot directly from the Latex-document with Gnuplot?

1
  • If you want to handle your graphs entirely within your Latex document, pgfplots probably offers better Latex-integration than gnuplot. Commented Apr 3, 2016 at 16:18

1 Answer 1

3

Basically u can just follow this Youtube-Tutorial

So here are the Steps:

Step 1: Set environment variables

After having installed MikTex, TexStudio and Gnuplot click on Start -> Rightclick on Computer -> Settings -> Advanced Systemsettings -> Environment variables

Here you have to create 3 new variables:

► PATH
C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files (x86)\gnuplot\bin

► gnuplot
C:\Program Files (x86)\gnuplot\bin

► GNUPLOT_LIB
C:\Program Files (x86)\gnuplot\demo

Step 2: Edit TexStudio Go to TexStudio and click on Options -> Configure TexStudio -> Commands

here you need to update the upper both commands

► LaTeX
"C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/latex.exe" -src -interaction=nonstopmode %.tex

► PdfLaTeX
pdflatex.exe -synctex=1 -shell-escape -enable-write18 -interaction=nonstopmode %.tex

Step 3: Code with Gnuplot in Latex

\documentclass[a4paper]{scrartcl}
\usepackage[miktex]{gnuplottex}

\begin{document}
\begin{figure}[H]
    \centering
    \begin{gnuplot}[terminal=pdf]
        set terminal pdf enhanced size 14.5cm, 4cm
        set key top left
        set xlabel 'x [1]'
        set ylabel 'y [1]'

        f1(x)=sin(x**2)

        plot f1(x) title 'y_1 = sin(x^2)'
    \end{gnuplot}
    \caption{Plot}
\end{figure}
\end{document}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.