# pgfplots: “x stick” style

I am trying to reproduce the following example. The xbar and ybar options are not really what I am looking for since I am only interested in having horizontal lines as markers of points.

Is there any way to do that in pgfplots ?

I assume that the length of the horizontal bars does not carry additional information, but is merely aesthetic. You can use the option mark=- to get horizontal lines, the thickness can be controlled with line width, the "radius" (i.e. half the length) can be set with mark size.

You didn't specifically ask for it, but since you said you're trying to reproduce the example, I also added symbolic x coordinates and and formatted the x tick labels to show the letter in brackets:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[only marks,
every axis plot post/.style={mark=-,ultra thick,mark size=4pt},
symbolic x coords={a,b,c,d},
xtick={a,b,c,d},
xticklabel={(\tick)}]
(a,-3.8)
(b,-4)
(c,-4)
(d,-1.9)};
(a,-8.25)
(b,-8.1)
(c,-8.1)
(d,-6.2)};
\end{axis}
\end{tikzpicture}

\end{document}


• I had tried the mark=- option but didn't thought of combining it with mark size to increase the length ! Anyway, that's exactly waht I was looking for. Many thanks for your prompt answer and the detailed explanation. – FFF Jun 5 '11 at 12:00
• I actually still have one question: when using the nodes near coords option to get values near markers, if two markers are too close, nodes are overlapping (set (a,-3.8) and (a,-3.75) for instance). Is it possible to specifically shift some of these automatically-generated nodes ? Thanks ! – FFF Jun 5 '11 at 12:38
• @FFF: There's no easy way to move individual markers. What I would probably do in your case is to use the option nodes near coords align=south option for the upper plot and nodes near coords align=north for the lower plot. However, this really only makes sense if one of the plots is always higher than the other. If you do need a way to move individual markers, you should probably ask a new question. Also, if you consider the current question about the horizontal markers to be answered, you should accept the answer by clicking the green tick mark. – Jake Jun 5 '11 at 14:39
• many thanks. Using something like nodes near coords align={anchor=south} was enough in my case to solve the overlapping problem. – FFF Jun 5 '11 at 15:48