pgfplots 1.10 released Print
News - LaTeX Graphics, Figures & Tables
Written by Stefan Kottwitz   
Friday, 07 March 2014 16:19

Version 1.10 of pgfplots has been released. It offers a new solution for fill the area between plots. Until now, people could use stacked plots to achieve such fillings or program it on their own. pgfplots now does it also with a focus on a minimum of required compiling time.

You can use it this way:

  • Load the library fillbetween: \usepgfplotslibrary{fillbetween}
  • Give the plots a name via name path=plot1 etc.
  • Add a fill between plot, such as
\addplot fill between[ 
  of = plot1 and plot2, 
  every even segment/.style = {color1},
  every odd segment/.style  = {color2},
Elke posted a complete example on
\pgfplotsset{compat=1.10} % mit writeLaTeX bisher noch nicht möglich

-2.5 0.5 -0.5 
-1 -1 1
0 0 0
1 1 -1
2.5 -0.5 0.5 

  \addplot[name path=plot1,green]table[x index={0}, y index={1}]{plotdata.dat}; 
  \addplot[name path=plot2,red]table[x index={0}, y index={2}]{plotdata.dat};
  % Füllung zwischen plots
  \addplot fill between[ 
    of=plot1 and plot2, 
    split, % Segmente berechnen lassen, Zählung beginnt bei 0 (also gerader Zahl)
    every even segment/.style= {green!10}, % Stil für die geraden Segmente
    every odd segment/.style={red!10}, % Stil für die ungeraden Segmente
Filled segments between plots

You can download the new version from SourceForge or from CTAN.