flopy.plot.map module

class DeprecatedMapView(model=None, modelgrid=None, ax=None, layer=0, extent=None)[source]

Bases: flopy.plot.map.PlotMapView

Deprecation handler for the PlotMapView class

Parameters:
  • model (flopy.modflow.Modflow object) –
  • modelgrid (flopy.discretization.Grid object) –
  • ax (matplotlib.pyplot.axes object) –
  • layer (int) – model layer to plot, default is layer 1
  • 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.
plot_discharge(frf, fff, dis=None, flf=None, head=None, istep=1, jstep=1, normalize=False, **kwargs)[source]

Use quiver to plot vectors. Deprecated method that uses the old function call to pass the method to PlotMapView

Parameters:
  • frf (numpy.ndarray) – MODFLOW’s ‘flow right face’
  • fff (numpy.ndarray) – MODFLOW’s ‘flow front face’
  • dis (flopy.modflow.ModflowDis package) – Depricated parameter
  • 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.
  • istep (int) – row frequency to plot. (Default is 1.)
  • jstep (int) – column 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 of specific discharge.

Return type:

matplotlib.pyplot.quiver

class ModelMap[source]

Bases: object

Pending Depreciation: ModelMap acts as a PlotMapView factory object. Please migrate to PlotMapView for plotting functionality and future code compatibility

Parameters:
  • sr (flopy.utils.reference.SpatialReference) – The spatial reference class (Default is None)
  • ax (matplotlib.pyplot axis) – The plot axis. If not provided it, plt.gca() will be used. If there is not a current axis then a new one will be created.
  • model (flopy.modflow object) – flopy model object. (Default is None)
  • dis (flopy.modflow.ModflowDis object) – flopy discretization object. (Default is None)
  • layer (int) – Layer to plot. Default is 0. Must be between 0 and nlay - 1.
  • xul (float) – x coordinate for upper left corner
  • yul (float) – y coordinate for upper left corner. The default is the sum of the delc array.
  • rotation (float) – Angle of grid rotation around the upper left corner. A positive value indicates clockwise rotation. Angles are in degrees.
  • 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.
  • length_multiplier (float) – scaling factor for conversion from model units to another unit length base ex. ft to m.

Notes

ModelMap must know the position and rotation of the grid in order to make the plot. This information is contained in the SpatialReference class (sr), which can be passed. If sr is None, then it looks for sr in dis. If dis is None, then it looks for sr in model.dis. If all of these arguments are none, then it uses xul, yul, and rotation. If none of these arguments are provided, then it puts the lower-left-hand corner of the grid at (0, 0).

class PlotMapView(model=None, modelgrid=None, ax=None, layer=0, extent=None)[source]

Bases: object

Class to create a map of the model. Delegates plotting functionality based on model grid type.

Parameters:
  • modelgrid (flopy.discretiztion.Grid) – The modelgrid class can be StructuredGrid, VertexGrid, or UnstructuredGrid (Default is None)
  • ax (matplotlib.pyplot axis) – The plot axis. If not provided it, plt.gca() will be used. If there is not a current axis then a new one will be created.
  • model (flopy.modflow object) – flopy model object. (Default is None)
  • layer (int) – Layer to plot. Default is 0. Must be between 0 and nlay - 1.
  • 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.

Notes

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

Contour an array. If the array is three-dimensional, then the method will contour the layer tied to this class (self.layer).

Parameters:
  • a (numpy.ndarray) – Array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.pcolormesh
Returns:

contour_set

Return type:

matplotlib.pyplot.contour

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

Contour a cvfd array. If the array is three-dimensional, then the method will contour the layer tied to this class (self.layer). The vertices must be in the same coordinates as the rotated and offset grid.

Parameters:
  • vertc (np.ndarray) – Array with of size (nc, 2) with centroid location of cvfd
  • a (numpy.ndarray) – Array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.pcolormesh
Returns:

contour_set

Return type:

matplotlib.pyplot.contour

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

Plot an array. If the array is three-dimensional, then the method will plot the layer tied to this class (self.layer).

Parameters:
  • a (numpy.ndarray) – Array to plot.
  • masked_values (iterable of floats, ints) – Values to mask.
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.pcolormesh
Returns:

quadmesh – matplotlib.collections.PatchCollection

Return type:

matplotlib.collections.QuadMesh or

plot_bc(name=None, package=None, kper=0, color=None, plotAll=False, **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)
  • plotAll (bool) – Boolean used to specify that boundary condition locations for all layers will be plotted on the current ModelMap layer. (Default is False)
  • **kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
Returns:

quadmesh

Return type:

matplotlib.collections.QuadMesh

plot_cvfd(verts, iverts, **kwargs)[source]

Plot a cvfd grid. The vertices must be in the same coordinates as the rotated and offset grid.

Parameters:
  • verts (ndarray) – 2d array of x and y points.
  • iverts (list of lists) – should be of len(ncells) with a list of vertex number for each cell
  • kwargs (dictionary) – Keyword arguments passed to plotutil.plot_cvfd()
plot_discharge(frf=None, fff=None, flf=None, head=None, istep=1, jstep=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.
  • istep (int) – row frequency to plot. (Default is 1.)
  • jstep (int) – column 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 of specific discharge.

Return type:

matplotlib.pyplot.quiver

plot_endpoint(ep, direction='ending', selection=None, selection_direction=None, **kwargs)[source]

Plot the MODPATH endpoints.

Parameters:
  • ep (rec array) – A numpy recarray with the endpoint particle data from the MODPATH 6 endpoint file
  • direction (str) – String defining if starting or ending particle locations should be considered. (default is ‘ending’)
  • selection (tuple) – tuple that defines the zero-base layer, row, column location (l, r, c) to use to make a selection of particle endpoints. The selection could be a well location to determine capture zone for the well. If selection is None, all particle endpoints for the user-sepcified direction will be plotted. (default is None)
  • selection_direction (str) – String defining is a selection should be made on starting or ending particle locations. If selection is not None and selection_direction is None, the selection direction will be set to the opposite of direction. (default is None)
  • kwargs (ax, c, s or size, colorbar, colorbar_label, shrink. The) – remaining kwargs are passed into the matplotlib scatter method. If colorbar is True a colorbar will be added to the plot. If colorbar_label is passed in and colorbar is True then colorbar_label will be passed to the colorbar set_label() method. If shrink is passed in and colorbar is True then the colorbar size will be set using shrink.
Returns:

sp

Return type:

matplotlib.pyplot.scatter

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', **kwargs)[source]

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

Parameters:
  • ibound (numpy.ndarray) – ibound array to plot. (Default is ibound in the modelgrid)
  • color_noflow (string) – (Default is ‘black’)
  • color_ch (string) – Color for constant heads (Default is ‘blue’.)
  • color_vpt (string) – Color for vertical pass through cells (Default is ‘red’)
Returns:

quadmesh

Return type:

matplotlib.collections.QuadMesh

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_pathline(pl, travel_time=None, **kwargs)[source]

Plot the MODPATH pathlines.

Parameters:
  • pl (list of rec arrays or a single rec array) – rec array or list of rec arrays is data returned from modpathfile PathlineFile get_data() or get_alldata() methods. Data in rec array is ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’.
  • travel_time (float or str) – travel_time is a travel time selection for the displayed pathlines. If a float is passed then pathlines with times less than or equal to the passed time are plotted. If a string is passed a variety logical constraints can be added in front of a time value to select pathlines for a select period of time. Valid logical constraints are <=, <, >=, and >. For example, to select all pathlines less than 10000 days travel_time=’< 10000’ would be passed to plot_pathline. (default is None)
  • kwargs (layer, ax, colors. The remaining kwargs are passed) – into the LineCollection constructor. If layer=’all’, pathlines are output for all layers
Returns:

lc

Return type:

matplotlib.collections.LineCollection

plot_shapefile(shp, **kwargs)[source]

Plot a shapefile. The shapefile must be in the same coordinates as the rotated and offset grid.

Parameters:
  • shp (string or pyshp shapefile object) – Name of the shapefile to plot
  • kwargs (dictionary) – Keyword arguments passed to plotutil.plot_shapefile()
plot_specific_discharge(spdis, istep=1, jstep=1, normalize=False, **kwargs)[source]

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

Method to plot specific discharge from discharge vectors provided by the cell by cell flow output file. In MODFLOW-6 this option is controled in the NPF options block. This method uses matplotlib quiver to create a matplotlib plot of the output.

Parameters:
  • spdis (np.recarray) – specific discharge recarray from cbc file
  • istep (int) – row frequency to plot. (Default is 1.)
  • jstep (int) – column frequency to plot. (Default is 1.)
  • kwargs (matplotlib.pyplot keyword arguments for the) – plt.quiver method.
Returns:

quiver – quiver plot of discharge vectors

Return type:

matplotlib.pyplot.quiver

plot_timeseries(ts, travel_time=None, **kwargs)[source]

Plot the MODPATH timeseries.

Parameters:
  • ts (list of rec arrays or a single rec array) – rec array or list of rec arrays is data returned from modpathfile TimeseriesFile get_data() or get_alldata() methods. Data in rec array is ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’.
  • travel_time (float or str) – travel_time is a travel time selection for the displayed pathlines. If a float is passed then pathlines with times less than or equal to the passed time are plotted. If a string is passed a variety logical constraints can be added in front of a time value to select pathlines for a select period of time. Valid logical constraints are <=, <, >=, and >. For example, to select all pathlines less than 10000 days travel_time=’< 10000’ would be passed to plot_pathline. (default is None)
  • kwargs (layer, ax, colors. The remaining kwargs are passed) – into the LineCollection constructor. If layer=’all’, pathlines are output for all layers
Returns:

lo

Return type:

list of Line2D objects

plot_vector(vx, vy, istep=1, jstep=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
  • istep (int) – row frequency to plot (default is 1)
  • jstep (int) – column 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