3

I recently ran into scaling problems with the very nice pgfplots library fillbetween. See the following example, which is perfectly fine:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[scale=1.0]

\begin{semilogxaxis}[xmin=1,xmax=256,grid=both,legend pos=north west,
            xlabel=Nb. of sub-domains,ylabel=Number of neighbors,legend cell align=left,
            every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},
            xtick={1,2,4,8,16,32,64,128,256},xticklabels={1,2,4,8,16,32,64,128,256}]
\legend{Min., Max., Average};

\addplot[color=blue,very thick,mark=*,name path=A] coordinates { (1,0) (2,1) (4,3) (8,4) (16,3) (32,3) (64,4) (128,4) (256,5) }; %Min
\addplot[color=gray,very thick,mark=*,name path=B] coordinates { (1,0) (2,1) (4,3) (8,6) (16,9) (32,12) (64,15) (128,15) (256,16)}; %Max
\addplot[color=black,very thick,mark=*] coordinates { (1,0) (2,1) (4,3) (8,5.5) (16,6.12) (32,7.88) (64,9.59) (128,10.50) (256,11.37)}; %Avg
\addplot[orange,opacity=0.4] fill between[of=A and B];

\end{semilogxaxis}

\end{tikzpicture} 

\end{document}

enter image description here

Now, I just change scale=1.0 to scale=0.8, and I obtain the following result:

enter image description here

Note that if I comment the "fillbetween" line in the code, everything works fine when scaling the picture. Does anyone has an idea about this ?

Cheers

2

Pass the scale=<factor> option to the axis environment and not to the tikzpicture environment:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}

\begin{semilogxaxis}[
  scale=0.8,
  xmin=1,xmax=256,grid=both,legend pos=north west,
            xlabel=Nb. of sub-domains,ylabel=Number of neighbors,legend cell align=left,
            every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},
            xtick={1,2,4,8,16,32,64,128,256},xticklabels={1,2,4,8,16,32,64,128,256}]
\legend{Min., Max., Average};

\addplot[color=blue,very thick,mark=*,name path=A] coordinates { (1,0) (2,1) (4,3) (8,4) (16,3) (32,3) (64,4) (128,4) (256,5) }; %Min
\addplot[color=gray,very thick,mark=*,name path=B] coordinates { (1,0) (2,1) (4,3) (8,6) (16,9) (32,12) (64,15) (128,15) (256,16)}; %Max
\addplot[color=black,very thick,mark=*] coordinates { (1,0) (2,1) (4,3) (8,5.5) (16,6.12) (32,7.88) (64,9.59) (128,10.50) (256,11.37)}; %Avg
\addplot[orange,opacity=0.4] fill between[of=A and B];

\end{semilogxaxis}

\end{tikzpicture} 

\end{document}

The result:

enter image description here

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.