第一个图的标签(由 \addlegendimage 添加)在两次编译后显示为默认黑色,这表明第一个图的引用尚未解析。代码如下:
\documentclass[12pt,twoside,openright]{report}
\usepackage{tikz,pgfplots,float}
\usepackage{csvsimple}
\usepgfplotslibrary{external}
\usetikzlibrary{external}
\tikzexternalize
\pgfplotsset{compat=newest}
\begin{document}
\begin{filecontents*}{curvas_tension_DC_y_vel_desacoplamiento_OWB_Hor.csv}
t;v_DC;vel_DCPM;vel_AFPM
0;0;0;0
0.5;0.5;1.25;0.125
1;1;5;1
1.5;1.5;11.25;3.375
2;2;20;8
2.5;2.5;31.25;15.625
3;3;45;27
3.5;3.5;61.25;42.875
4;4;80;64
4.5;4.5;101.25;91.125
5;5;125;125
5.5;5.5;151.25;166.375
6;6;180;216
6.5;6.5;211.25;274.625
\end{filecontents*}
\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
ymin=0, ymax=6.75,
xmin=0, xmax=6.75,
grid,
xtick={0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5},
ytick={0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5},
axis y line*=left, % the '*' avoids arrow heads
xlabel={$t$ [s]},
xlabel near ticks,
ylabel={$v_{fuente}$ [V]},
ylabel near ticks,
width=\textwidth,
height=0.7\textwidth,
]
\addplot[ultra thick,violet!17] table[x=t, y=v_DC,col sep=semicolon]{curvas_tension_DC_y_vel_desacoplamiento_OWB_Hor.csv}; \label{plot_one}
\end{axis}
\begin{axis}[
ymin=0, ymax=325,
xmin=0, xmax=6.75,
ytick={0,50,100,150,200,250,300},
hide x axis,
axis y line*=right,
ylabel={Velocidad [rpm]},
ylabel near ticks,
width=\textwidth,
height=0.7\textwidth,
]
\addlegendimage{/pgfplots/refstyle=plot_one}\addlegendentry{$v_{fuente}$}
\addplot[no markers,teal] table[x=t, y=vel_DCPM,col sep=semicolon]{curvas_tension_DC_y_vel_desacoplamiento_OWB_Hor.csv};
\addlegendentry{$n _{m \, in}$};
\addplot[no markers,orange] table[x=t, y=vel_AFPM,col sep=semicolon]{curvas_tension_DC_y_vel_desacoplamiento_OWB_Hor.csv};
\addlegendentry{$n _{m \, out}$};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
这里您可以找到.csv 文件。
为此,我遵循了这里。
提前致谢。