我想在我的文本中引用一些图表(用 pgfplots 完成),但不知何故这是不可能的。
如果我从 pgfplot- 文档中复制粘贴示例,它可以工作,但如果我将其中一个标签移动到我的图中,它会在第二次编译时中断(只要引用呈现为“??”就可以了)。
这是我收到的错误:
! Package pgfkeys Error: I do not know the key '/tikz/plot' and I am going to i
gnore it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.105 Here the legend image \ref{pgfplots:plot2}
is displayed correctly.
?
Der Prozess wurde vom Benutzer abgebrochen
顺便说一下,引用传说作品中的相同情节。
\documentclass{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}[plot/.style={very thick,raw gnuplot,mark=none,black}]
\begin{axis}[
legend cell align=left, minor y tick num=3, minor x tick num=1, width=0.5\textwidth, domain=-pi/2:pi/2,
ymin=0, ymax=1.3, xmin=-1.571, xmax=1.571, grid=both, y=5cm, axis y line=left, axis x line=bottom]
\addplot gnuplot [plot,red]
{ ag1(x) = 0.33*sin(x);plot[-pi/2:pi/2]ag1(x)};
\label{pgfplots:label4}
\addlegendentry{$\delta_1=10 \ref{pgfplots:label3}$};
\addplot gnuplot [plot,green]
{ag1(x) = 0.33*cos(x);plot[-pi/2:pi/2]ag1(x)};
\label{pgfplots:label3}
\addlegendentry{$\delta_1=10 \ref{pgfplots:label4}$};
\end{axis} \end{tikzpicture} \begin{tikzpicture}[baseline] \begin{axis}
\addplot+ {3*x+2.5*rand};
\label{pgfplots:label1}
\addplot+[mark=none] {3*x};
\label{pgfplots:label2}
\addplot {4*cos(deg(x))};
% \label{pgfplots:label3} %IF THIS LINE ISN'T A COMMENT IT WORKS
\end{axis}
\end{tikzpicture}
\section{References}
\ref{pgfplots:label1}\\
\ref{pgfplots:label2}\\
% \ref{pgfplots:label3}\\
\end{document}
所以我有两张图片 - 如果 label3 在下面的图片中它就可以工作,如果它在另一张图片中它就不会编译。
答案1
pgfplots:label3
由于您引用的是图外标记的图,并且该图是使用该plot
样式生成的,因此您需要全局声明此样式;否则,像在代码中一样仅在本地拥有它,当引用发生时,该样式在图外是未知的:
\documentclass{article}
\usepackage{tikz,pgfplots}
\tikzset{
plot/.style={very thick,raw gnuplot,mark=none,black}
}
\begin{document}
\begin{tikzpicture}[]
\begin{axis}[
legend cell align=left,
minor y tick num=3,
minor x tick num=1,
width=0.5\textwidth,
domain=-pi/2:pi/2,
ymin=0,
ymax=1.3,
xmin=-1.57079632679,
xmax=1.57079632679,
grid=both,
y=5cm,
axis y line=left,
axis x line=bottom,
xlabel={$\varphi [^\circ]$},
ylabel=$a^{(c)}$]
\addplot gnuplot [plot,dashdotted]{
ag0(x) = +0.330477 -2.06663*(x/pi)**2 +2.90481*(x/pi)**4 +0.296334*(x/pi)**6;
ag1(x) = -0.398712 +3.35323*(x/pi)**2 -8.06845*(x/pi)**4 +4.13977*(x/pi)**6;
ag2(x) = -0.1077 -0.990205*(x/pi)**2 +8.82304*(x/pi)**4 -12.5561*(x/pi)**6;
ag3(x) = +0.226138 -0.545837*(x/pi)**2 -3.58968*(x/pi)**4 +8.61929*(x/pi)**6;
ag(x,y)= ag0(x)+(log(y)/6)*(ag1(x)+(log(y)/6)*(ag2(x)+(log(y)/6)*(ag3(x))));
plot[-pi/2:pi/2]ag(x,100);
};
\label{pgfplots:label3}
\addlegendentry{$\delta_1=10 $\ref{pgfplots:label3}};
\end{axis}
\end{tikzpicture}\begin{tikzpicture}[baseline]
\begin{axis}
\addplot+[only marks,
samples=15,
error bars/y dir=both,
error bars/y fixed=2.5]
{3*x+2.5*rand};
\label{pgfplots:label1}
\addplot+[mark=none] {3*x};
\label{pgfplots:label2}
\addplot {4*cos(deg(x))};
%\label{pgfplots:label3} %NOW IT WORKS
\end{axis}
\end{tikzpicture}
\section{References}
\ref{pgfplots:label1}\\
\ref{pgfplots:label2}\\
\ref{pgfplots:label3}\\
\end{document}