# Filled contour plot

> Level sets of a function of two variables, filled with a colormap, seen from above. A pgfplots example with its LaTeX source.

A pgfplots example in the TeXeR TikZ library: https://texer.org/library/pgfplots/filled-contour

Package: [pgfplots](https://texer.org/library/pgfplots.md), on CTAN at https://ctan.org/pkg/pgfplots.

Tags: contour, level sets, colormap, two variables

## Source

```latex
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{tikzpicture}
  \begin{axis}[
    view={0}{90}, width=8cm, height=7cm,
    xlabel=$x$, ylabel=$y$, colorbar, colormap/viridis,
    axis equal image, enlargelimits=false,
  ]
    \addplot3[contour filled={number=12}, domain=-2:2, domain y=-2:2, samples=41]
    {exp(-x^2 - y^2) - 0.7*exp(-(x - 1)^2 - (y - 1)^2)};
  \end{axis}
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
    view={0}{90}, width=8cm, height=7cm,
    xlabel=$x$, ylabel=$y$, colorbar, colormap/viridis,
    axis equal image, enlargelimits=false,
  ]
    \addplot3[contour filled={number=12}, domain=-2:2, domain y=-2:2, samples=41]
    {exp(-x^2 - y^2) - 0.7*exp(-(x - 1)^2 - (y - 1)^2)};
  \end{axis}
\end{tikzpicture}
\end{document}
```
