matplotlib 中的 pgfplot 给出错误消息

matplotlib 中的 pgfplot 给出错误消息

我已经在 python 中创建了一些图并使用模块“另存为 tikz_save”将它们导出,因此在 python 中我通过以下方式创建这些输出文件:

tikz_save(original+'/'+nameOfFigurepgf+'.pgf')

然后我想通过以下方式将这些文件包含在乳胶中:

\documentclass[]{article}

\usepackage{subfig}
\usepackage{pgfplots}
\newlength\figureheight
\newlength\figurewidth

\usepackage{hyperref}

\usepackage[]{grffile}
\begin{document}




\begin{figure}
\hspace{-2cm}
\begin{minipage}{1.\textwidth}

  \subfloat[test]{%

  \setlength\figureheight{2in}
    \setlength\figurewidth{3in}
    \InputIfFileExists{C:/....pgf}{}{\textbf{!! Missing graphics !!}}

  }
     \subfloat[test]{%

  \setlength\figureheight{2in}
    \setlength\figurewidth{3in}
    \InputIfFileExists{C:....pgf}{}{\textbf{!! Missing graphics !!}}



 }

\end{minipage} \par
 \centering
  \subfloat[]{%

   \setlength\figureheight{2in}
    \setlength\figurewidth{4in}
    \InputIfFileExists{C:/....pgf}{}{\textbf{!! Missing graphics !!}}
  }
  \caption{Some grouped images}
\end{figure}

tex tikz 文件如下所示

%This file was created by matplotlib2tikz v0.6.12.
\begin{tikzpicture}

\definecolor{color1}{rgb}{1,0.498039215686275,0.0549019607843137}
\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}

\begin{axis}[
xlabel={wavelength (nm)},
ylabel={Intensity (a.u.)},
xmin=524.676077346168, xmax=943.742025261725,
ymin=-0.00222843895038663, ymax=0.0432368644418556,
ytick={-0.01,0,0.01,0.02,0.03,0.04,0.05},
yticklabels={,0.00,0.01,0.02,0.03,0.04,},
tick align=outside,
tick pos=left,
x grid style={lightgray!92.026143790849673!black},
y grid style={lightgray!92.026143790849673!black},
legend style={draw=white!80.0!black},
legend entries={{2017 August 18 18_19_02.csv},{Referenz}},
legend cell align={left}
]
\addlegendimage{no markers, color0}
\addlegendimage{no markers, color1}
\addplot [semithick, color0]
table {%

923.135104433213 -5.95462246777672e-05
923.394857361311 0.000178638674033302
923.654607029838 0.000142910939226641
923.914353437571 4.76369797422138e-05
924.174096583282 9.52739594844275e-05
924.433836465749 0.000107183204419981
924.693573083745 0
};
\path [draw=black, fill opacity=0] (axis cs:0,-0.00222843895038663)
--(axis cs:0,0.0432368644418556);

\path [draw=black, fill opacity=0] (axis cs:1,-0.00222843895038663)
--(axis cs:1,0.0432368644418556);

\path [draw=black, fill opacity=0] (axis cs:524.676077346168,0)
--(axis cs:943.742025261725,0);

\path [draw=black, fill opacity=0] (axis cs:524.676077346168,1)
--(axis cs:943.742025261725,1);

\node at (axis cs:820,0.03)[
  scale=0.5,
  anchor=base west,
  text=black,
  rotate=0.0
]{\itshape Shifted by 19.38 nm};
\end{axis} %(line 1377)

\end{tikzpicture}

如果我尝试编译 tex 文件,我总是收到相同的错误消息

! Missing $ inserted.
<inserted text>
$
l.1377 \end{axis}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Extra }, or forgotten $.
\pgfplots@already@computed@legend@node ..._02.csv}
;\\};
l.1377 \end{axis}

尤其是这条信息

! Missing } inserted.
<inserted text>
}
l.1377 \end{axis}
I've put in what seems to be necessary to fix
the current column of the current alignment.
Try to go on, since this might almost work.
! Extra }, or forgotten $.
<inserted text> } 

显示多次。

相关内容