【问题标题】:How to plot in Latex with Gnuplot?如何使用 Gnuplot 在 Latex 中绘图?
【发布时间】:2016-04-03 14:27:39
【问题描述】:

之前我使用过 Gnuplot 并创建了一个 pdf-file,然后我在我的 Latex-document 中通过 includegraphics 实现了该文件。

难道没有更好的方法直接从Latex-document 和Gnuplot 绘图吗?

【问题讨论】:

  • 如果您想完全在 Latex 文档中处理图表,pgfplots 可能提供比 gnuplot 更好的 Latex 集成。

标签: latex gnuplot


【解决方案1】:

基本上你可以关注这个Youtube-Tutorial

以下是步骤:

第一步:设置环境变量

安装MikTexTexStudioGnuplot后点击Start -> 右击Computer -> Settings -> Advanced Systemsettings -> Environment variables

在这里你必须创建 3 个新变量:

► 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

第 2 步:编辑 TexStudio 进入 TexStudio 并点击 Options -> Configure TexStudio -> 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

第 3 步:在 Latex 中使用 Gnuplot 编写代码

\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}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多