I have "superimposed" different plots on the same graph (i.e., I have two axis
es environments in one tikzpicture
environment.)
Now I would like to add a single legend for both of the plots and place it outside (at the bottom) of the graph.
I have read How can legend entries be obtained from different plots in a groupplot?, but the solution doesn't work for me because it involves multiple tikzpicture
s.
Here is my MWE:
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\usepackage{sansmath}
\usepackage{tikz}
\tikzset{%
font=\sansmath\sffamily,
}
\usepackage{pgfplots}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% legend columns=-1, % <---- Doesn't work
% legend entries={blue;,red},
% legend to name=named,
xlabel={Specific Impulse [s]},
ylabel style={blue},
y axis line style={blue},
ytick style={blue},
yticklabel style={blue},
axis x line*=bottom,
axis y line*=left,
tick align = outside,
scaled y ticks=base 10:-3,
]
\addplot [
color=blue,
mark=*,
line width=1.5pt,
mark size=2.5pt,
]
table [x=Isp,y=mpropLEO] {OUTprop.dat};
\end{axis}
\begin{axis}[
ylabel style={red},
y axis line style={red},
ytick style={red},
yticklabel style={red},
axis x line*=none,
axis y line*=right,
hide x axis,
tick align=outside,
]
\addplot [
color=red,
mark=square*,
line width=1.5pt,
mark size=2.5pt,
]
table [x=Isp,y=N] {OUTprop.dat};
\end{axis}
\end{tikzpicture}
\end{document}
and the OUTprop.dat
file is:
Isp mpropLEO N
200 296199.130625 0
225 178727.998632 -6
250 118317.300031 5
275 83818.963766 3
300 62498.670491 3
325 48488.756284 2
350 38822.104550 2
375 31882.745911 2
400 26735.688678 2
425 22812.101477 2
450 19750.977297 2
475 17314.797071 2
500 15342.358783 2
Can someone help me?