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.

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 trying to get my graph to fit inside of the graph's dimensions (4in by 7.5in). I want the ymin of the graph to be the minimum y value of all my points and the ymax value the maximum y value for all of my points (so that my graph fits snugly but doesn't get cut off).

My graph seems to go outside of the boundaries. I've tried to use enlargelimits=true but it adds too much whitespace.

I've also tried enlarge y limits={true, abs value=0.75}, and many different variations, however it doesn't appear to affect the graph at all.

I could use xmin and xmax but I have ~20 graphs, and I don't really want to change each separately.

        enlarge y limits={true, abs value=0.75},
        xlabel=Atomic Number,
        ylabel=Atomic Radius $(in$ $pm)$,
        enlargelimits = false,
        extra x ticks={1,84},
        title={\large Atomic Number vs. Atomic Radius $(in$ $pm)$}]
    \addplot[smooth,mark=none,black] plot coordinates {
(1,37.1) (2,31) (3,152) (4,112) (5,85) (6,77.2) (7,70) (8,73) (9,72) (10,71) (11,186) (12,160) (13,143) (14,117.6) (15,110) (16,103) (17,100) (18,98) (19,227) (20,197) (21,162) (22,147) (23,134) (24,128) (25,127) (26,126) (27,125) (28,124) (29,128) (30,134) (31,135) (32,122.3) (33,120) (34,119) (35,114) (36,112) (37,248) (38,215) (39,180) (40,160) (41,146) (42,139) (43,136) (44,134) (45,134) (46,137) (47,144) (48,151) (49,167) (50,140.5) (51,140) (52,142) (53,133) (54,131) (55,265) (56,222) (57,187) (58,182) (59,182) (60,181) (61,183) (62,180) (63,208) (64,180) (65,177) (66,178) (67,176) (68,176) (69,176) (70,193) (71,174) (72,159) (73,146) (74,139) (75,137) (76,135) (77,136) (78,139) (79,144) (80,151) (81,170) (82,146) (83,150) (84,168)     };


enter image description here

share|improve this question
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. – percusse Oct 27 '12 at 14:05
Yep, I already added it! It's the graph around x=1 – alexy13 Oct 27 '12 at 14:08
MWE is meant to be the code producing it. Please check the link in my previous comment. – percusse Oct 27 '12 at 14:09
@alexy13: An MWE should be a complete minimal document, so something beginning with \documentclass that can just be copied into a new document to get a compilable .tex file. Otherwise everyone who wants to try and help needs to complete the file themselves, which is not a whole lot of fun. – Jake Oct 27 '12 at 14:37
up vote 8 down vote accepted

Setting enlargelimits=false, as you've done, causes PGFPlots to adjust the limits so that all the data points are just visible. However, this does not take into account the overshooting introduced by the smooth style. So you'll need to adjust the limits, using something like (as you've attempted) enlarge y limits={true, abs value=5}. However, you also need to remove the enlargelimits=false, otherwise you'll override the setting.

I would recommend not using the smooth style, however: As you've noticed, it doesn't accurately represent the data due to the overshooting. Also, smoothing the data makes it seem like you have much more data than you actually do, so it's not entirely honest.

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.