TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I go about putting a grid in front of a bar chart in PGFPlots, preferably as automagically as possible? Ed Tufte demonstrates a rather appealing way of drawing bar charts in The Visual Display of Quantitative Information that consists of removing horizontal grid lines from the bars (example centre), and it occurs to me that this can be replicated by drawing white horizontal lines over the chart, or perhaps through some other route.

Any ideas?

share|improve this question
Perhaps this would help? tex.stackexchange.com/questions/9559/… – Martin Tapankov Mar 10 '11 at 6:12
Good suggestion, however unfortunately it doesn't. help lines can indeed be made to draw on top of the chart, however their spacing has no correspondence to the PGFPlots coordinate system of the chart. – Richard Terrett Mar 10 '11 at 6:19
up vote 9 down vote accepted

There's an axis on top for the axis environment that can be used to achieve what you asked for:


  axis lines*=left,
  axis on top,
  grid style={white}]
\addplot [fill=black] coordinates { (0,2) (1,1.5) (2,3)};
\addplot [draw=black!40,fill=black!40] coordinates { (0,2.2) (1,1.1) (2,5.1)};

bar chart with y grid on top

share|improve this answer
Perfect, exactly what I was looking for. Thank you. – Richard Terrett Mar 10 '11 at 6:21

Your Answer


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.