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

I'm plotting bar plot using this code:

%Define standard arrow tip
\pgfplotsset{every axis/.append style={
line width=1 pt,
tick style={line width=.6pt}}}
    axis background/.style={shade,top color=gray,bottom color=white},
    bar width=1.2cm,
    minor y tick num=4,
    legend style={at={(0.5,-0.2)},
      anchor=north,legend columns=-1},
    symbolic x coords={5--10 years,10--15 years, 15--20 years,20--25 years,Over 25 years},
        nodes near coords, 
        nodes near coords align={vertical},
        x tick label style={font=\normalsize,text width=1.5cm,align=center},
        ]    \addplot[fill=green!25!gray] coordinates {(5--10 years,32) (10--15 years,12) (15--20 years,3) (20--25 years,2) (Over 25 years,3)};


enter image description here

I want to have y minimum equal to 0. I have set:


But as you can see, it does not work.

Please help to solve this problem.

And secondly. How to put values inside of the bar?

Thank you in advance.

share|improve this question
Remove the enlargelimits=0.15 if you don't want to enlarge the limits of the axis past the specified ymin value. To put the nodes inside the bars, use every node near coord/.append style={anchor=north}. – Jake Jan 30 '14 at 18:14
Thank you! It works. But why enlargelimits=0.15 make such effect? – saldenisov Jan 30 '14 at 19:14
@saldenisov: Because that's what enlargelimits is designed to do. From the pgfplots manual: "Axis limits can be increased automatically using the enlargelimits option." – Paul Gessler Jan 30 '14 at 19:31
But if I need to use enlargelimits t effect x axis? What than should I do?Thank you. – saldenisov Jan 30 '14 at 19:37
up vote 4 down vote accepted

pgfplots, by default, uses enlargelimits=0.15 in all directions.
You can change this to enlarge x limits=0.15 to only enlarge the limits in x direction, which then looks like this:

enlarge x limits=0.15

where nodes near coords manages to expand the y axis enough to include the nodes, but enlarge x limits=0.15,enlarge y limits={value=0.15,upper}, gives the more equally spaced lower picture.

enlarge x limits=0.15,enlarge y limits={value=0.15,upper}

share|improve this answer

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.