imod.visualize - Customized plots

Module to provide functions to create customized plots.

These functions build on existing libraries, and merely serve as a shorthand for plots that may be useful to evaluate groundwater models. All xarray.DataArray and pandas.DataFrame objects have .plot() or .imshow() methods to plot them directly.

imod.visualize.cross_section(da, layers=False, ax=None, **kwargs)[source]

Wraps matplotlib.pcolormesh to draw cross-sections, drawing cell boundaries accurately.

  • da (xr.DataArray) – Two dimensional DataArray containing data of the cross section. The first dimension must be “layer”, and the second dimension will be used as the x-axis for the cross-section. Coordinates “top” and “bottom” must be present.

  • layers (boolean, optional) – Whether to draw lines separating the layers.

  • ax (, optional) – Matplotlib axes object on which the cross-section will be drawn.

  • **kwargs – Other optional keyword argument for matplotlib.pcolormesh.


Return type


imod.visualize.plot_map(raster, colors, levels, overlays=[], kwargs_raster=None, kwargs_colorbar=None, figsize=None)[source]
  • raster (xr.DataArray) – 2D grid to plot.

  • colors (list of str, or list of RGB tuples) –

    Matplotlib acceptable list of colors. Length N. Accepts both tuples of (R, G, B) and hexidecimal (e.g. “#7ec0ee”).

    Looking for good colormaps? Try: Choose a colormap, and use the HEX JS array.

  • levels (listlike of floats or integers) – Boundaries between the legend colors/classes. Length: N - 1.

  • overlays (list of dicts, optional) – Dicts contain geodataframe (key is “gdf”), and the keyword arguments for plotting the geodataframe.

  • kwargs_raster (dict of keyword arguments, optional) – These arguments are forwarded to ax.imshow()

  • kwargs_colorbar (dict of keyword arguments, optional) – These arguments are forwarded to fig.colorbar()

  • figsize (tuple of two floats or integers, optional) – This is used in plt.subplots(figsize)


  • fig (matplotlib.figure)

  • ax (


Plot with an overlay:

>>> overlays = [{"gdf": geodataframe, "edgecolor": "black"}]
>>> imod.visualize.spatial.plot_map(raster, legend, overlays)

path (str) – Path to iMOD .leg file.


  • colors (List of hex colors of length N.)

  • levels (List of floats of length N-1. These are the boundaries between) – the legend colors/classes.