# Shading the area bounded by graphs in TikZ

Thanks to Torbjørn T.'s answer at Best way to generate a nice function plots in LaTeX?, there is an easy way to show multiple graphs using TikZ's datavisualization. Is there a way to shade i.e. fill in the region bounded by these graphs?

• An MWE of the two functions on one axis would be useful. – John Kormylo Nov 29 '16 at 20:08
• As an aside, if you're not locked to the datavisualization library, you could look at pgfplots. Search the site for e.g. [pgfplots] fill between – Torbjørn T. Nov 29 '16 at 20:16

## 1 Answer

Try:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[name path=f] {x^2 - x +4};
\addplot[name path=g] {x^2 - x};
\addplot [
fill=blue,
fill opacity=0.2
]
fill between[
of=f and g
];
\end{axis}
\end{tikzpicture}
\end{document}


Output:

• Is there a way to do it with datavisualization? – An Hoa Nov 29 '16 at 21:01
• Sorry, didn't read that part of your question. – Hood Chatham Nov 30 '16 at 0:34