I'm trying to use the method outline in Graphics: Area between curves to create a graph of the area between two curves to insert into a solution sheet. However, when I do, the box is placed incorrectly. The tikzpicture ends up way higher than it should be, rather than being in line, and so covers up text, or other pictures placed above it. My code is as follows:




The box for the tikzpicture appears to be much higher than it should be.\\
    ymin=-1, ymax=6,
        xtick = {-1,1},
    ytick = {1,2,3,4,5,6},
    axis lines=center,
    axis line style = <->,
        ticklabel style = {font=\small}

\addplot[name path=F,domain={0:5}] {x};
\addplot[name path=G,domain={0:5}] {(x-2)^2};
\addplot[pattern=north west lines, pattern color=gray!50]fill between[of=F and G, soft clip={domain=1:4}];
  • 1
    This seems to be a "scaling" problem/bug. If you comment the scaleing factor or set it to 1 everything seems to work fine. – Stefan Pinnow Feb 14 '17 at 21:11

As I already stated in the comment below the question I consider this being a bug which I have reported to the PGFPlots Tracker.

There is a workaround to get the desired result. Have a look at the comments in the code on how to do it.

The box for the tikzpicture appears to be much higher than it should be.

% this line causes the mess ...
%    scale=0.75,
        % ... as a workaround just scale the default axis `width' directly with
        % the factor to get the desired result
        xmin=0,     xmax=5,
        ymin=-1,    ymax=6,
        axis lines=center,
        axis line style=<->,
        ticklabel style={font=\small}
        \addplot [name path=F,domain={0:5}] {x};
        \addplot [name path=G,domain={0:5}] {(x-2)^2};
        \addplot [
            pattern=north west lines,
            pattern color=gray!50,
        ] fill between [
            of=F and G,
            soft clip={domain=1:4},

image showing a zoomed region of the above code

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.