imod.visualize.cross_section#

imod.visualize.cross_section(da, colors, levels, layers=False, aquitards=None, kwargs_pcolormesh={}, kwargs_colorbar={}, kwargs_aquitards=None, return_cmap_norm=False, fig=None, ax=None)[source]#

Wraps matplotlib.pcolormesh to draw cross-sections, drawing cell boundaries accurately. Aquitards can be plotted on top of the cross-section, by providing a DataArray with the aquitard location for aquitards.

Parameters:
  • da (xr.DataArray) –

    Two dimensional DataArray containing data of the cross section. One 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, and must have at least the “layer” dimension (voxels) or both the “layer” and x-coordinate dimension.

    Use imod.select.cross_section_line() or cross_section_linestring() to obtain the required DataArray.

  • 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: http://colorbrewer2.org/ Choose a colormap, and use the HEX JS array.

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

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

  • aquitards (xr.DataArray, optional) – Datarray containing data on location of aquitard layers.

  • kwargs_pcolormesh (dict) – Other optional keyword arguments for matplotlib.pcolormesh.

  • kwargs_colorbar (dict) – Optional keyword argument whiten_triangles whitens respective colorbar triangle if data is not larger/smaller than legend_levels-range. Defaults to True. Other arguments are forwarded to fig.colorbar()

  • kwargs_aquitards (dict) – These arguments are forwarded to matplotlib.fill_between to draw the aquitards.

  • return_cmap_norm (boolean, optional) – Return the cmap and norm of the plot, default False

  • fig (matplotlib Figure instance, optional) – Figure to write plot to. If not supplied, a Figure instance is created

  • ax (matplotlib Axes instance, optional) – Axes to write plot to. If not supplied, an Axes instance is created

Returns:

  • fig (matplotlib.figure)

  • ax (matplotlig.ax)

  • if return_cmap_norm == True

  • cmap (matplotlib.colors.ListedColormap)

  • norm (matplotlib.colors.BoundaryNorm)

Examples

Basic cross section:

>>> imod.visualize.cross_section(da, colors, levels)

Aquitards can be styled in multiple ways. For a transparent grey overlay (the default):

>>> kwargs_aquitards = {"alpha": 0.5, "facecolor": "grey"}
>>> imod.visualize.cross_section(da, colors, levels, aquitards=aquitards, kwargs_aquitards)

For a hatched overlay:

>>> kwargs_aquitards = {"hatch": "/", "edgecolor": "k"}
>>> imod.visualize.cross_section(da, colors, levels, aquitards=aquitards, kwargs_aquitards)