Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

With the help of \pgfdeclareplotmark I defined a custom mark for a plot and it worked as expected; however, in the legend, the mark appears with a vertical shift. What is causing this problem and how can it be prevented?

\documentclass{article}
\usepackage{pgfplotstable}
\usetikzlibrary{shadows}
\pgfplotsset{compat=1.8} 

\pgfdeclareplotmark{*)}
  {\shade[draw=green!60!black,ball color=green!70] (0,0) circle [radius=5pt];}

\begin{document}

\begin{tikzpicture}
\begin{axis}[]
\addplot+[mark=*)]  
coordinates {
 (-2,3)
 (1,-5)
};
\addlegendentry{test}
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 10 down vote accepted

Interestingly, this can be fixed by using (0pt, 0pt) instead of (0,0) in the plot mark definition. Some PGF vs. TikZ problem, perhaps.

\documentclass{article}
\usepackage{pgfplotstable}
\usetikzlibrary{shadows}
\pgfplotsset{compat=1.8} 

\pgfdeclareplotmark{*)}
  {\shade[draw=green!60!black,ball color=green!70] (0pt, 0pt) circle [radius=5pt];}

\begin{document}

\begin{tikzpicture}
\begin{axis}[]
\addplot+[mark=*)]  
coordinates {
 (-2,3)
 (1,-5)
};
\addlegendentry{test}
\end{axis}
\end{tikzpicture}

\end{document}

share|improve this answer
    
Ha! I tried almost everything, except the simplest thing :-) Thank you, Jake. –  Gonzalo Medina Jul 25 '13 at 17:20
    
Indeed (0,0) is the origin of the corrected legend box but the legend bounding box increases due to the wrongly placed ball. This is most probably due to the TikZ parsing of the coordinate inside the pgf pen syntax. –  percusse Jul 25 '13 at 17:28
    
Jake and @percusse: would you say this is a bug, a feature, or simply a mistake I made by not providing explicitly a unit? –  Gonzalo Medina Jul 26 '13 at 2:49
2  
@GonzaloMedina I think it is unpredictable behavior. Consider using \pgfdeclareplotmark{*)}{ \tikzset{ball color=green!70} \pgfsetstrokecolor{green!60!black} \pgfpathcircle{\pgfpoint{0}{0}}{5pt} \pgfshadepath{ball}{0} \pgfusepath{stroke}} then there is no issue whether there is pt or not (you can even use \pgfpointorigin). Does that make it a bug? Jake and Christian know way better than me. –  percusse Jul 26 '13 at 8:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.