flopy.plot.plotbase module

class DeprecatedCrossSection(ax=None, model=None, modelgrid=None, line=None, extent=None)[source]

Bases: flopy.plot.plotbase.PlotCrossSection

Deprecation handler for the PlotCrossSection class

Parameters:
  • ax (matplotlib.pyplot.axes object) –
  • model (flopy.modflow.Modflow object) –
  • modelgrid (flopy.discretization.Grid object) –
  • line (dict) – Dictionary with either “row”, “column”, or “line” key. If key is “row” or “column” key value should be the zero-based row or column index for cross-section. If key is “line” value should be an array of (x, y) tuples with vertices of cross-section. Vertices should be in map coordinates consistent with xul, yul, and rotation.
  • extent (tuple of floats) – (xmin, xmax, ymin, ymax) will be used to specify axes limits. If None then these will be calculated based on grid, coordinates, and rotation.
class PlotCrossSection(model=None, modelgrid=None, ax=None, line=None, extent=None, geographic_coords=False)[source]

Bases: object

Class to create a cross section of the model.

Parameters:
  • ax (matplotlib.pyplot axis) – The plot axis. If not provided it, plt.gca() will be used.
  • model (flopy.modflow object) – flopy model object. (Default is None)
  • modelgrid (flopy.discretization.Grid object) – can be a StructuredGrid, VertexGrid, or UnstructuredGrid object
  • line (dict) – Dictionary with either “row”, “column”, or “line” key. If key is “row” or “column” key value should be the zero-based row or column index for cross-section. If key is “line” value should be an array of (x, y) tuples with vertices of cross-section. Vertices should be in map coordinates consistent with xul, yul, and rotation.
  • extent (tuple of floats) – (xmin, xmax, ymin, ymax) will be used to specify axes limits. If None then these will be calculated based on grid, coordinates, and rotation.
  • geographic_coords (bool) – boolean flag to allow the user to plot cross section lines in geographic coordinates. If False (default), cross section is plotted as the distance along the cross section line.
contour_array(a, masked_values=None, head=None, **kwargs)[source]

Contour a three-dimensional array.

Parameters:
  • a (numpy.ndarray) – Three-dimensional array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.contour
Returns:

contour_set

Return type:

matplotlib.pyplot.contour

get_grid_line_collection(**kwargs)[source]

Get a LineCollection of the grid

Parameters:**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.LineCollection
Returns:linecollection
Return type:matplotlib.collections.LineCollection
get_grid_patch_collection(zpts, plotarray, **kwargs)[source]

Get a PatchCollection of plotarray in unmasked cells

Parameters:
  • zpts (numpy.ndarray) – array of z elevations that correspond to the x, y, and horizontal distance along the cross-section (self.xpts). Constructed using plotutil.cell_value_points().
  • plotarray (numpy.ndarray) – Three-dimensional array to attach to the Patch Collection.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
Returns:

patches

Return type:

matplotlib.collections.PatchCollection

plot_array(a, masked_values=None, head=None, **kwargs)[source]

Plot a three-dimensional array as a patch collection.

Parameters:
  • a (numpy.ndarray) – Three-dimensional array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
Returns:

patches

Return type:

matplotlib.collections.PatchCollection

plot_bc(name=None, package=None, kper=0, color=None, head=None, **kwargs)[source]

Plot boundary conditions locations for a specific boundary type from a flopy model

Parameters:
  • name (string) – Package name string (‘WEL’, ‘GHB’, etc.). (Default is None)
  • package (flopy.modflow.Modflow package class instance) – flopy package class instance. (Default is None)
  • kper (int) – Stress period to plot
  • color (string) – matplotlib color string. (Default is None)
  • head (numpy.ndarray) – Three-dimensional array (structured grid) or Two-dimensional array (vertex grid) to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
Returns:

patches

Return type:

matplotlib.collections.PatchCollection

plot_discharge(frf, fff, flf=None, head=None, kstep=1, hstep=1, normalize=False, **kwargs)[source]

DEPRECATED. Use plot_vector() instead, which should follow after postprocessing.get_specific_discharge().

Use quiver to plot vectors.

Parameters:
  • frf (numpy.ndarray) – MODFLOW’s ‘flow right face’
  • fff (numpy.ndarray) – MODFLOW’s ‘flow front face’
  • flf (numpy.ndarray) – MODFLOW’s ‘flow lower face’ (Default is None.)
  • head (numpy.ndarray) – MODFLOW’s head array. If not provided, then will assume confined conditions in order to calculated saturated thickness.
  • kstep (int) – layer frequency to plot. (Default is 1.)
  • hstep (int) – horizontal frequency to plot. (Default is 1.)
  • normalize (bool) – boolean flag used to determine if discharge vectors should be normalized using the magnitude of the specific discharge in each cell. (default is False)
  • kwargs (dictionary) – Keyword arguments passed to plt.quiver()
Returns:

quiver – Vectors

Return type:

matplotlib.pyplot.quiver

plot_fill_between(a, colors=('blue', 'red'), masked_values=None, head=None, **kwargs)[source]

Plot a three-dimensional array as lines.

Parameters:
  • a (numpy.ndarray) – Three-dimensional array to plot.
  • colors (list) – matplotlib fill colors, two required
  • masked_values (iterable of floats, ints) – Values to mask.
  • head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.plot
Returns:

plot

Return type:

list containing matplotlib.fillbetween objects

plot_grid(**kwargs)[source]

Plot the grid lines.

Parameters:kwargs (ax, colors. The remaining kwargs are passed into the) – the LineCollection constructor.
Returns:lc
Return type:matplotlib.collections.LineCollection
plot_ibound(ibound=None, color_noflow='black', color_ch='blue', color_vpt='red', head=None, **kwargs)[source]

Make a plot of ibound. If not specified, then pull ibound from the self.model

Parameters:
  • ibound (numpy.ndarray) – ibound array to plot. (Default is ibound in ‘BAS6’ package.)
  • color_noflow (string) – (Default is ‘black’)
  • color_ch (string) – Color for constant heads (Default is ‘blue’.)
  • head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
Returns:

patches

Return type:

matplotlib.collections.PatchCollection

plot_inactive(ibound=None, color_noflow='black', **kwargs)[source]

Make a plot of inactive cells. If not specified, then pull ibound from the self.ml

Parameters:
  • ibound (numpy.ndarray) – ibound array to plot. (Default is ibound in ‘BAS6’ package.)
  • color_noflow (string) – (Default is ‘black’)
Returns:

quadmesh

Return type:

matplotlib.collections.QuadMesh

plot_specific_discharge(spdis, head=None, kstep=1, hstep=1, normalize=False, **kwargs)[source]

DEPRECATED. Use plot_vector() instead, which should follow after postprocessing.get_specific_discharge().

Use quiver to plot vectors.

Parameters:
  • spdis (np.recarray) – numpy recarray of specific discharge information. This can be grabbed directly from the CBC file if SAVE_SPECIFIC_DISCHARGE is used in the MF6 NPF file.
  • head (numpy.ndarray) – MODFLOW’s head array. If not provided, then the quivers will be plotted in the cell center.
  • kstep (int) – layer frequency to plot. (Default is 1.)
  • hstep (int) – horizontal frequency to plot. (Default is 1.)
  • normalize (bool) – boolean flag used to determine if discharge vectors should be normalized using the magnitude of the specific discharge in each cell. (default is False)
  • kwargs (dictionary) – Keyword arguments passed to plt.quiver()
Returns:

quiver – Vectors

Return type:

matplotlib.pyplot.quiver

plot_surface(a, masked_values=None, **kwargs)[source]

Plot a two- or three-dimensional array as line(s).

Parameters:
  • a (numpy.ndarray) – Two- or three-dimensional array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.plot
Returns:

plot

Return type:

list containing matplotlib.plot objects

plot_vector(vx, vy, vz, head=None, kstep=1, hstep=1, normalize=False, masked_values=None, **kwargs)[source]

Plot a vector.

Parameters:
  • vx (np.ndarray) – x component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
  • vy (np.ndarray) – y component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
  • vz (np.ndarray) – y component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
  • head (numpy.ndarray) – MODFLOW’s head array. If not provided, then the quivers will be plotted in the cell center.
  • kstep (int) – layer frequency to plot (default is 1)
  • hstep (int) – horizontal frequency to plot (default is 1)
  • normalize (bool) – boolean flag used to determine if vectors should be normalized using the vector magnitude in each cell (default is False)
  • masked_values (iterable of floats) – values to mask
  • kwargs (matplotlib.pyplot keyword arguments for the) – plt.quiver method
Returns:

quiver – result of the quiver function

Return type:

matplotlib.pyplot.quiver