Graphics, Figures & Tablespgfplots | Wrong Marks in Legend

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kat_e
Posts: 9
Joined: Sun Sep 09, 2012 5:04 pm

pgfplots | Wrong Marks in Legend

Post by kat_e »

I'm using pgfplots to plot the below data with their linear regression. The problem I'm encountering is that the markers are filled black in the graph but empty in the legend. Does anyone know where the incorrect code is?

Code: Select all

\documentclass[10pt,a4paper]{report}
\usepackage{pgfplots,pgfplotstable}

\begin{document}
  \begin{figure}
    \centering
    \begin{tikzpicture}
      \begin{axis}[
        legend image post style={},
        ylabel=Apparent density{,} $g\,cm^{-3}$,
        xlabel=Schopper-Riegler drainability{,} \emph{SR},
        legend entries={Reference, NaOH}, 
        legend style={
          at={(0.97,0.35)},
          cells={anchor=west}
        }
      ]
       \addplot [only marks] table [x=X,y=Y]{data/chap4/RF_wetness_density.dat};
       \addplot [no markers, forget plot] table [x=X,y={create col/linear regression={y=Y}}]{data/chap4/RF_wetness_density.dat};
       \addplot [only marks, mark=square*] table [x=X,y=Y]{data/chap4/SH_wetness_density.dat};
       \addplot [no markers, forget plot] table [x=X,y={create col/linear regression={y=Y}}]{data/chap4/SH_wetness_density.dat};
      \end{axis}
    \end{tikzpicture}
  \end{figure}
\end{document}
The data tables are:

The file "RF_wetness_density.dat"

Code: Select all

X	Y	
21	0.34
42	0.41
65	0.47
78	0.50
82	0.54
The file "SH_wetness_density.dat"

Code: Select all

X	Y
11	0.31
23	0.38
30	0.43
54	0.49
68	0.52

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: pgfplots | Wrong Marks in Legend

Post by localghost »

Seems to be a bug. I'd suggest to write a note to the package maintainer. He's also a member of this board and visits quite regularly.


Thorsten
kat_e
Posts: 9
Joined: Sun Sep 09, 2012 5:04 pm

Re: pgfplots | Wrong Marks in Legend

Post by kat_e »

thanks Thorsten. I've sent a message to him now.

kind regards,
Katie
kat_e
Posts: 9
Joined: Sun Sep 09, 2012 5:04 pm

pgfplots | Wrong Marks in Legend

Post by kat_e »

Found it! Forgot to put a "+" after \addplot so correct code would be

Code: Select all

\documentclass[a4paper,10pt]{report}
\usepackage{pgfplots,pgfplotstable}


\begin{document}

 \begin{figure}
\centering

\begin{tikzpicture}
\begin{axis}[legend image post style={}
,ylabel=Apparent density{,} $g\,cm^{-3}$,xlabel=Schopper-Riegler drainability{,} \emph{SR},legend entries={Reference, NaOH}, 
legend style={at={(0.97,0.35)}, cells={anchor=west}
}]

\addplot+[only marks] table [x=X,y=Y]{data/chap4/RF_wetness_density.dat};
\addplot+[no markers, forget plot] table [x=X,y={create col/linear regression={y=Y}}]{data/chap4/RF_wetness_density.dat};
\addplot+[only marks, mark=square*] table [x=X,y=Y]{data/chap4/SH_wetness_density.dat};
\addplot+[no markers, forget plot] table [x=X,y={create col/linear regression={y=Y}}]{data/chap4/SH_wetness_density.dat};

\end{axis}

\end{tikzpicture}
 
\end{figure}

\end{document}
Kind regards,
Katie
Post Reply