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.

I'm trying to plot some intervals with pgfplots and wanted to use a custom mark for upper and lower bound. I planned doing this by using a "V" for the upper bound and a "^" for the lower bound (ideally not the letters but symbols that look like the upper and lower half of an X). The idea here is that both symbols will merge into an X for empty intervals.

I guess I could get symbols like those with text mark={v} but the alignment would be off, as pgfplots would center the mark instead of using the tip of the "v" as its baseline.

Any idea how I could get the alignment right?

share|improve this question
add comment

2 Answers

PGFPlots can use any plot mark which is defined in pgf. You may want to study pgflibraryplotmarks.code.tex (which is shipped with pgf) and define a mark accordingly.

The alignment is simple: at the time when plot marks are drawn, the origin (0pt,0pt) is the marks position. Simply make sure that your V has y>0pt and ^ has y < 0pt, that's all.

share|improve this answer
    
Thanks, thats what I found, when I was looking at the definition of the existing plot marks in the source code. I tried to add an answer here but I don't have enough reputation yet, so I have to wait for 7 more hours. I will add the answer tomorrow. If someone discovers the question in the meantime: the answer involves using \pgfdeclareplotmark, \pgfpathmoveto, \pgfpathlineto and \pgfplotmarksize –  Flogo Sep 7 '11 at 18:04
add comment
up vote 3 down vote accepted

I found a solution after looking in the pgfplots source code. With the following definition I got the plot marks I wanted

\pgfdeclareplotmark{v}{%
  \pgfpathmoveto{\pgfpoint{-\pgfplotmarksize}{\pgfplotmarksize}}
  \pgfpathlineto{\pgfpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfpoint{\pgfplotmarksize}{\pgfplotmarksize}}
  \pgfusepathqstroke
}
\pgfdeclareplotmark{^}{%
  \pgfpathmoveto{\pgfpoint{-\pgfplotmarksize}{-\pgfplotmarksize}}
  \pgfpathlineto{\pgfpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfpoint{\pgfplotmarksize}{-\pgfplotmarksize}}
  \pgfusepathqstroke
}

After the definition the marks can be used like any other mark, e.g.

\addplot[only marks, mark=^] coordinates { (0,0) }
\addplot[only marks, mark=v] coordinates { (0,1) }
\addplot[mark=none] coordinates { (0,0) (0,1) }
share|improve this answer
add comment

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.