Saturday, 24 August 2013

Customize marker and line style for a legend outside of an axis (pgfplots with TeXworks)

Customize marker and line style for a legend outside of an axis (pgfplots
with TeXworks)

Nice to finally post a question myself after finding solutions to my
problems on numerous occasions within these forums. I hope someone can be
of help (and that this hasn't been asked already).
The problem is as follows: I'm using pgfplots for the plots within my
document. I used the procedure described in section 4.8.7 (Legends outside
of an axis) within the pgfplots manual in order to create one legend for
several horizontally aligned plots. In general this works fine. My issue
is, that the marker style differs between the plot and the legend. I am
using the no markers option with \addplot. The legend shows the correct
line style but also markers. Is it possible to remove the markers? Did I
place the ref{} command to reference the legend in the wrong place? I
couldn't find any solution by browsing google or within the manual, hence
my question.
The code looks as follows (I can post a minimum working example if
necessary):
\begin{figure}[htb]
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
legend columns=-1,
legend entries={$Pe_{ax} = 1$;,$Pe_{ax} = 10$;,$Pe_{ax} = 100$;,$Pe_{ax} =
1000$},
legend to name=named3,
width=6cm, height=6cm,
xmin={0},
xmax={2},
ymin={0},
ymax={2},
xtick={0,1,2},
ytick={0,2},
xlabel= {$\Theta [-]$},
ylabel={$E(\Theta) [-]$},
label style={font=\footnotesize},
tick label style={font=\footnotesize},
legend style={draw=none}
]
\addplot+[no markers,smooth, color=black, dashed] coordinates {(1,0) (1,2)};
\addplot+[no markers,smooth, color=black, dotted] table[x=X,y=Y1]
{Tabellen/Butt_1999_Bo1.txt};
\addplot+[no markers,smooth, color=black, dashdotdotted] table[x=X,y=Y1]
{Tabellen/Butt_1999_Bo10.txt};
\addplot+[no markers,smooth, color=black, dashdotted] table[x=X,y=Y1]
{Tabellen/Butt_1999_Bo100.txt};
\addplot+[no markers,smooth, color=black, solid] table[x=X,y=Y1]
{Tabellen/Butt_1999_Bo1000.txt};
\end{axis}
\end{tikzpicture}
\hspace{0cm}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
width=6cm, height=6cm,
xmin={0},
xmax={2},
ymin={0},
ymax={1},
xtick={0,1,2},
ytick={0,1},
xlabel= {$\Theta [-]$},
ylabel={$F(\Theta) [-]$},
label style={font=\footnotesize},
tick label style={font=\footnotesize}
]
\addplot+[no markers,smooth, color=black, dashed] coordinates {(1,0) (1,1)};
\addplot+[no markers,smooth, color=black, dotted] table[x=X,y=Y2]
{Tabellen/Butt_1999_Bo1.txt};
\addplot+[no markers,smooth, color=black, dashdotdotted] table[x=X,y=Y2]
{Tabellen/Butt_1999_Bo10.txt};
\addplot+[no markers,smooth, color=black, dashdotted] table[x=X,y=Y2]
{Tabellen/Butt_1999_Bo100.txt};
\addplot+[no markers,smooth, color=black, solid] table[x=X,y=Y2]
{Tabellen/Butt_1999_Bo1000.txt};
\end{axis}
\end{tikzpicture}
\ref{named3}
\caption{Text.}
\end{figure}
Hope this helps! Thanks in advance for any ideas, thoughts and the like!

No comments:

Post a Comment