我正在尝试将 gnuplot 图形输出到 tikz 代码。我尝试在 gnuplot 中使用 set terminal lua tikz terminal。Gnuplot 在\begin{tikzpicture}[gnuplot] environment
...中发出了相应的代码\end{tikzpicture}
,这就是我需要的。我不知道如何在 LaTeX 文档中正确使用它。tikzpicture
环境有,例如,\draw[gp path] (1.196,2.963)--(1.376,2.963);
什么是 gpath?pdflatex 对此感到愤怒并发出错误。
我打开 gnuplot 并输入
set terminal lua tikz
plot sin(x)
并获取代码
\begin{tikzpicture}[gnuplot]
%% generated with GNUPLOT 5.4p3 (Lua 5.4; terminal rev. Jun 2020, script rev. 115)
%% 11.03.2022 19:02:33
\path (0.000,0.000) rectangle (12.500,8.750);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetdashtype{gp dt solid}
\gpsetlinewidth{1.00}
\draw[gp path] (1.196,0.616)--(1.376,0.616);
\draw[gp path] (11.947,0.616)--(11.767,0.616);
\node[gp node right] at (1.012,0.616) {$-1$};
\draw[gp path] (1.196,1.398)--(1.376,1.398);
\draw[gp path] (11.947,1.398)--(11.767,1.398);
\node[gp node right] at (1.012,1.398) {$-0.8$};
\draw[gp path] (1.196,2.181)--(1.376,2.181);
\draw[gp path] (11.947,2.181)--(11.767,2.181);
\node[gp node right] at (1.012,2.181) {$-0.6$};
\draw[gp path] (1.196,2.963)--(1.376,2.963);
\draw[gp path] (11.947,2.963)--(11.767,2.963);
\node[gp node right] at (1.012,2.963) {$-0.4$};
\draw[gp path] (1.196,3.746)--(1.376,3.746);
\draw[gp path] (11.947,3.746)--(11.767,3.746);
\node[gp node right] at (1.012,3.746) {$-0.2$};
\draw[gp path] (1.196,4.529)--(1.376,4.529);
\draw[gp path] (11.947,4.529)--(11.767,4.529);
\node[gp node right] at (1.012,4.529) {$0$};
\draw[gp path] (1.196,5.311)--(1.376,5.311);
\draw[gp path] (11.947,5.311)--(11.767,5.311);
\node[gp node right] at (1.012,5.311) {$0.2$};
\draw[gp path] (1.196,6.094)--(1.376,6.094);
\draw[gp path] (11.947,6.094)--(11.767,6.094);
\node[gp node right] at (1.012,6.094) {$0.4$};
\draw[gp path] (1.196,6.876)--(1.376,6.876);
\draw[gp path] (11.947,6.876)--(11.767,6.876);
\node[gp node right] at (1.012,6.876) {$0.6$};
\draw[gp path] (1.196,7.659)--(1.376,7.659);
\draw[gp path] (11.947,7.659)--(11.767,7.659);
\node[gp node right] at (1.012,7.659) {$0.8$};
\draw[gp path] (1.196,8.441)--(1.376,8.441);
\draw[gp path] (11.947,8.441)--(11.767,8.441);
\node[gp node right] at (1.012,8.441) {$1$};
\draw[gp path] (1.196,0.616)--(1.196,0.796);
\draw[gp path] (1.196,8.441)--(1.196,8.261);
\node[gp node center] at (1.196,0.308) {$-10$};
\draw[gp path] (3.884,0.616)--(3.884,0.796);
\draw[gp path] (3.884,8.441)--(3.884,8.261);
\node[gp node center] at (3.884,0.308) {$-5$};
\draw[gp path] (6.572,0.616)--(6.572,0.796);
\draw[gp path] (6.572,8.441)--(6.572,8.261);
\node[gp node center] at (6.572,0.308) {$0$};
\draw[gp path] (9.259,0.616)--(9.259,0.796);
\draw[gp path] (9.259,8.441)--(9.259,8.261);
\node[gp node center] at (9.259,0.308) {$5$};
\draw[gp path] (11.947,0.616)--(11.947,0.796);
\draw[gp path] (11.947,8.441)--(11.947,8.261);
\node[gp node center] at (11.947,0.308) {$10$};
\draw[gp path] (1.196,8.441)--(1.196,0.616)--(11.947,0.616)--(11.947,8.441)--cycle;
\node[gp node right] at (10.479,8.107) {$sin(x)$};
\gpcolor{rgb color={0.580,0.000,0.827}}
\draw[gp path] (10.663,8.107)--(11.579,8.107);
\draw[gp path] (1.196,6.657)--(1.305,5.955)--(1.413,5.195)--(1.522,4.408)--(1.630,3.626)%
--(1.739,2.880)--(1.848,2.202)--(1.956,1.618)--(2.065,1.152)--(2.173,0.824)--(2.282,0.647)%
--(2.391,0.627)--(2.499,0.766)--(2.608,1.059)--(2.716,1.492)--(2.825,2.049)--(2.934,2.706)%
--(3.042,3.438)--(3.151,4.214)--(3.259,5.003)--(3.368,5.773)--(3.477,6.492)--(3.585,7.131)%
--(3.694,7.664)--(3.802,8.070)--(3.911,8.332)--(4.019,8.439)--(4.128,8.387)--(4.237,8.178)%
--(4.345,7.820)--(4.454,7.329)--(4.562,6.724)--(4.671,6.030)--(4.780,5.274)--(4.888,4.488)%
--(4.997,3.704)--(5.105,2.953)--(5.214,2.267)--(5.323,1.672)--(5.431,1.194)--(5.540,0.851)%
--(5.648,0.658)--(5.757,0.622)--(5.866,0.745)--(5.974,1.022)--(6.083,1.442)--(6.191,1.987)%
--(6.300,2.635)--(6.409,3.361)--(6.517,4.134)--(6.626,4.923)--(6.734,5.696)--(6.843,6.422)%
--(6.952,7.070)--(7.060,7.615)--(7.169,8.035)--(7.277,8.312)--(7.386,8.435)--(7.495,8.399)%
--(7.603,8.206)--(7.712,7.863)--(7.820,7.385)--(7.929,6.790)--(8.038,6.104)--(8.146,5.353)%
--(8.255,4.569)--(8.363,3.783)--(8.472,3.027)--(8.581,2.333)--(8.689,1.728)--(8.798,1.237)%
--(8.906,0.879)--(9.015,0.670)--(9.124,0.618)--(9.232,0.725)--(9.341,0.987)--(9.449,1.393)%
--(9.558,1.926)--(9.666,2.565)--(9.775,3.284)--(9.884,4.054)--(9.992,4.843)--(10.101,5.619)%
--(10.209,6.351)--(10.318,7.008)--(10.427,7.565)--(10.535,7.998)--(10.644,8.291)--(10.752,8.430)%
--(10.861,8.410)--(10.970,8.233)--(11.078,7.905)--(11.187,7.439)--(11.295,6.855)--(11.404,6.177)%
--(11.513,5.431)--(11.621,4.649)--(11.730,3.862)--(11.838,3.102)--(11.947,2.400);
\gpcolor{color=gp lt color border}
\draw[gp path] (1.196,8.441)--(1.196,0.616)--(11.947,0.616)--(11.947,8.441)--cycle;
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.196cm}{0.616cm}}{\pgfpoint{11.947cm}{8.441cm}}
\end{tikzpicture}
但在编译时
\documentclass[12pt,a4paper]{article}
\usepackage{cmap}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}
\usepackage{indentfirst}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage[miktex]{gnuplottex}
\begin{document}
\begin{tikzpicture}[gnuplot]
%% generated with GNUPLOT 5.4p3 (Lua 5.4; terminal rev. Jun 2020, script rev. 115)
%% 11.03.2022 19:02:33
\path (0.000,0.000) rectangle (12.500,8.750);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetdashtype{gp dt solid}
\gpsetlinewidth{1.00}
\draw[gp path] (1.196,0.616)--(1.376,0.616);
\draw[gp path] (11.947,0.616)--(11.767,0.616);
\node[gp node right] at (1.012,0.616) {$-1$};
\draw[gp path] (1.196,1.398)--(1.376,1.398);
\draw[gp path] (11.947,1.398)--(11.767,1.398);
\node[gp node right] at (1.012,1.398) {$-0.8$};
\draw[gp path] (1.196,2.181)--(1.376,2.181);
\draw[gp path] (11.947,2.181)--(11.767,2.181);
\node[gp node right] at (1.012,2.181) {$-0.6$};
\draw[gp path] (1.196,2.963)--(1.376,2.963);
\draw[gp path] (11.947,2.963)--(11.767,2.963);
\node[gp node right] at (1.012,2.963) {$-0.4$};
\draw[gp path] (1.196,3.746)--(1.376,3.746);
\draw[gp path] (11.947,3.746)--(11.767,3.746);
\node[gp node right] at (1.012,3.746) {$-0.2$};
\draw[gp path] (1.196,4.529)--(1.376,4.529);
\draw[gp path] (11.947,4.529)--(11.767,4.529);
\node[gp node right] at (1.012,4.529) {$0$};
\draw[gp path] (1.196,5.311)--(1.376,5.311);
\draw[gp path] (11.947,5.311)--(11.767,5.311);
\node[gp node right] at (1.012,5.311) {$0.2$};
\draw[gp path] (1.196,6.094)--(1.376,6.094);
\draw[gp path] (11.947,6.094)--(11.767,6.094);
\node[gp node right] at (1.012,6.094) {$0.4$};
\draw[gp path] (1.196,6.876)--(1.376,6.876);
\draw[gp path] (11.947,6.876)--(11.767,6.876);
\node[gp node right] at (1.012,6.876) {$0.6$};
\draw[gp path] (1.196,7.659)--(1.376,7.659);
\draw[gp path] (11.947,7.659)--(11.767,7.659);
\node[gp node right] at (1.012,7.659) {$0.8$};
\draw[gp path] (1.196,8.441)--(1.376,8.441);
\draw[gp path] (11.947,8.441)--(11.767,8.441);
\node[gp node right] at (1.012,8.441) {$1$};
\draw[gp path] (1.196,0.616)--(1.196,0.796);
\draw[gp path] (1.196,8.441)--(1.196,8.261);
\node[gp node center] at (1.196,0.308) {$-10$};
\draw[gp path] (3.884,0.616)--(3.884,0.796);
\draw[gp path] (3.884,8.441)--(3.884,8.261);
\node[gp node center] at (3.884,0.308) {$-5$};
\draw[gp path] (6.572,0.616)--(6.572,0.796);
\draw[gp path] (6.572,8.441)--(6.572,8.261);
\node[gp node center] at (6.572,0.308) {$0$};
\draw[gp path] (9.259,0.616)--(9.259,0.796);
\draw[gp path] (9.259,8.441)--(9.259,8.261);
\node[gp node center] at (9.259,0.308) {$5$};
\draw[gp path] (11.947,0.616)--(11.947,0.796);
\draw[gp path] (11.947,8.441)--(11.947,8.261);
\node[gp node center] at (11.947,0.308) {$10$};
\draw[gp path] (1.196,8.441)--(1.196,0.616)--(11.947,0.616)--(11.947,8.441)--cycle;
\node[gp node right] at (10.479,8.107) {$sin(x)$};
\gpcolor{rgb color={0.580,0.000,0.827}}
\draw[gp path] (10.663,8.107)--(11.579,8.107);
\draw[gp path] (1.196,6.657)--(1.305,5.955)--(1.413,5.195)--(1.522,4.408)--(1.630,3.626)%
--(1.739,2.880)--(1.848,2.202)--(1.956,1.618)--(2.065,1.152)--(2.173,0.824)--(2.282,0.647)%
--(2.391,0.627)--(2.499,0.766)--(2.608,1.059)--(2.716,1.492)--(2.825,2.049)--(2.934,2.706)%
--(3.042,3.438)--(3.151,4.214)--(3.259,5.003)--(3.368,5.773)--(3.477,6.492)--(3.585,7.131)%
--(3.694,7.664)--(3.802,8.070)--(3.911,8.332)--(4.019,8.439)--(4.128,8.387)--(4.237,8.178)%
--(4.345,7.820)--(4.454,7.329)--(4.562,6.724)--(4.671,6.030)--(4.780,5.274)--(4.888,4.488)%
--(4.997,3.704)--(5.105,2.953)--(5.214,2.267)--(5.323,1.672)--(5.431,1.194)--(5.540,0.851)%
--(5.648,0.658)--(5.757,0.622)--(5.866,0.745)--(5.974,1.022)--(6.083,1.442)--(6.191,1.987)%
--(6.300,2.635)--(6.409,3.361)--(6.517,4.134)--(6.626,4.923)--(6.734,5.696)--(6.843,6.422)%
--(6.952,7.070)--(7.060,7.615)--(7.169,8.035)--(7.277,8.312)--(7.386,8.435)--(7.495,8.399)%
--(7.603,8.206)--(7.712,7.863)--(7.820,7.385)--(7.929,6.790)--(8.038,6.104)--(8.146,5.353)%
--(8.255,4.569)--(8.363,3.783)--(8.472,3.027)--(8.581,2.333)--(8.689,1.728)--(8.798,1.237)%
--(8.906,0.879)--(9.015,0.670)--(9.124,0.618)--(9.232,0.725)--(9.341,0.987)--(9.449,1.393)%
--(9.558,1.926)--(9.666,2.565)--(9.775,3.284)--(9.884,4.054)--(9.992,4.843)--(10.101,5.619)%
--(10.209,6.351)--(10.318,7.008)--(10.427,7.565)--(10.535,7.998)--(10.644,8.291)--(10.752,8.430)%
--(10.861,8.410)--(10.970,8.233)--(11.078,7.905)--(11.187,7.439)--(11.295,6.855)--(11.404,6.177)%
--(11.513,5.431)--(11.621,4.649)--(11.730,3.862)--(11.838,3.102)--(11.947,2.400);
\gpcolor{color=gp lt color border}
\draw[gp path] (1.196,8.441)--(1.196,0.616)--(11.947,0.616)--(11.947,8.441)--cycle;
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.196cm}{0.616cm}}{\pgfpoint{11.947cm}{8.441cm}}
\end{tikzpicture}
\end{document}
它给出了一个错误
Package pgfkeys Error: I do not know the key '/tikz/gp node center' and I am going to ignore it. Perhaps you misspelled it. \node[gp node center]