I need to specify different "enlarge x limits" for the lower and upper axis extrema. Something like enlarge x limits={{value=0.2,upper}, {value=0.4,lower}} does not work however. Any ideas? Using xmin and xmax to modify the range first is not an option as I use "symbolic x coords".


\begin{axis}[ybar,ymin=0,symbolic x coords={a,b,c}, enlarge x limits=true, xtick=data, legend pos=south east]
\addplot coordinates { (a,10) (b,15) (c,20) };

Here I want to make room at lower side to show the bar properly and add more whitespace at the upper side to make room for the legend (I prefer to keep the legend inside the plot).

  • 1
    Welcome to TeX.SE. It is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. I also helps to test that the solution indeed does work. Oct 4 '11 at 15:05
  • tex.stackexchange.com/questions/74497/… I found the helpful response given by @zeroth to this question under this link.
    – forrest
    May 13 '15 at 18:42

PGFPlots uses the same value for both upper and lower limit in enlarge * limits; the use-case of different values is unsupported (sorry). You may need to consider a different solution.

  • 3
    This seems to be possible by now using the upper and lower keys to enlargelimits or enlarge * limits (found in the manual of version 1.16 on page 329, section 4.14.1).
    – Alex Povel
    Aug 23 '19 at 16:37
  • @AlexPovel: How? OP writes that exactly that does not work. You can specify one, but not both. Oct 7 at 15:50
  • @Christian Feuersänger: Just to be sure - it is still not possible!? I wanted to have used it in my answer here: tex.stackexchange.com/a/618105/8650 Oct 7 at 16:39

Without a MWE I am not sure I fully understand the problem. But, it appears that using xmax to specify the upper limit even with symbolic x coords seems to work fine. Here I specified xmax=i, and did not specify xmin:

enter image description here


\begin{axis}[xmax=i,symbolic x coords={a,b,c,d,e,f,g,h,i}]
    \addplot+[smooth] coordinates { (a,42) (b,50) (c,80) (f,60) (g,62) (i,90)};

If I have misunderstood your question, please provide a specific compilable example.

  • The example is representative enough, but the problem is that you cannot extend the whitespace using xmax, only limit it to the last datapoint. I need to extend the whitespace both at the upper and lower end, but in different proportions.
    – Johan
    Oct 5 '11 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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