The label of the first plot (added by \addlegendimage) appears in default black after two compilations which indicates that the reference of the first plot is not being resolved. Here is the code:
\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}
Here you can find the .csv file.
For this I followed the example in the accepted answer in here.
Thanks in advance.
\usepackage{pgpflots}and removing the erroneous\pgfplotsset{tikz}I get https://i.stack.imgur.com/pNZpA.png, so seems like your code works fine? – Torbjørn T. Nov 02 '22 at 18:38\pgfplotssetbefore\usepackage{pgfplots}. Edit: and another error because of the\FloatBarrier. – Torbjørn T. Nov 02 '22 at 18:55\usepgfplotslibrary{external}and there is a problem somewhere, but this library is not loaded in the code you show here. Just to be sure: do you get that warning from this code (of course after correcting both errors thatTorbjørn mentioned, i.e., moving
\pgfplotssetone line down and removing\FloatBarrier)? – Marijn Nov 02 '22 at 20:12\pgfplotssetand\FloatBarrier). This means the code still doesn't reproduce the issue. Please take care to test the MWE before posting/editing it. – Marijn Nov 02 '22 at 20:59\FloatBarrieris a command from theplaceinspackage, that you didn't load in the MWE. Overleaf ignores errors by default, which often leads to incorrect output but some output is always shown if possible - maybe you missed the error message because of this. – Marijn Nov 02 '22 at 21:17