flopy.plot.map module
- 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.discretization.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, tri_mask=False, **kwargs)[source]
Contour an array on the grid. By default the top layer is contoured. To select a different layer, specify the layer in the class constructor.
For structured and vertex grids, the array may be 1D, 2D or 3D. For unstructured grids, the array must be 1D or 2D.
- Parameters:
a (1D, 2D or 3D array-like) – Array to plot.
masked_values (iterable of floats, ints) – Values to mask.
tri_mask (bool) – Boolean flag that masks triangulation and contouring by nearest grid neighbors. This flag is useful for contouring on unstructured model domains that have holes in the grid.
**kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.pcolormesh
- Returns:
contour_set
- Return type:
matplotlib.pyplot.contour
- property 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:
- plot_endpoint(ep, direction='ending', selection=None, selection_direction=None, **kwargs)[source]
Plot particle endpoints. Compatible with MODFLOW 6 PRT particle track data format, or MODPATH 6 or 7 endpoint data format.
- Parameters:
ep (recarray or dataframe) –
A numpy recarray with the endpoint particle data from the MODPATH endpoint file.
For MODFLOW 6 PRT pathlines, columns must include ‘x’, ‘y’, ‘z’, ‘t’, ‘trelease’, ‘imdl’, ‘iprp’, ‘irpt’, and ‘ilay’. Additional columns are ignored. Note that MODFLOW 6 PRT does not assign to particles a unique ID, but infers particle identity from ‘imdl’, ‘iprp’, ‘irpt’, and ‘trelease’ combos (i.e. via composite key).
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 – The PathCollection added to the plot.
- Return type:
- 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:
- 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:
- 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:
- plot_pathline(pl, travel_time=None, **kwargs)[source]
Plot particle pathlines. Compatible with MODFLOW 6 PRT particle track data format, or MODPATH 6 or 7 pathline data format.
- Parameters:
pl (list of recarrays or dataframes, or a single recarray or dataframe) –
Particle pathline data. If a list of recarrays or dataframes, each must contain the path of only a single particle. If just one recarray or dataframe, it should contain the paths of all particles. The flopy.utils.modpathfile.PathlineFile.get_data() or get_alldata() return value may be passed directly as this argument.
For MODPATH 6 or 7 pathlines, columns must include ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’. Additional columns are ignored.
For MODFLOW 6 PRT pathlines, columns must include ‘x’, ‘y’, ‘z’, ‘t’, ‘trelease’, ‘imdl’, ‘iprp’, ‘irpt’, and ‘ilay’. Additional columns are ignored. Note that MODFLOW 6 PRT does not assign to particles a unique ID, but infers particle identity from ‘imdl’, ‘iprp’, ‘irpt’, and ‘trelease’ combos (i.e. via composite key).
travel_time (float or str) – Travel time selection. If a float, then pathlines with total time less than or equal to the given value are plotted. If a string, the value must be a comparison operator, then a time value. Valid operators are <=, <, ==, >=, and >. For example, to filter pathlines with less than 10000 units of total time traveled, use ‘< 10000’. (Default is None.)
kwargs (dict) – Explicitly supported kwargs are layer, ax, colors. Any remaining kwargs are passed into the LineCollection constructor. If layer=’all’, pathlines are shown for all layers.
- Returns:
lc – The pathlines added to the plot.
- Return type:
- plot_shapefile(shp, **kwargs)[source]
Plot a shapefile. The shapefile must be in the same coordinates as the rotated and offset grid.
- Parameters:
shp (str, os.PathLike or pyshp shapefile object) – Path of the shapefile to plot
kwargs (dictionary) – Keyword arguments passed to plotutil.plot_shapefile()
- plot_shapes(obj, **kwargs)[source]
Plot shapes is a method that facilitates plotting a collection of geospatial objects
- Parameters:
obj (collection object) –
obj can accept the following types
str : shapefile path PathLike : shapefile path shapefile.Reader object list of [shapefile.Shape, shapefile.Shape,] shapefile.Shapes object flopy.utils.geometry.Collection object list of [flopy.utils.geometry, …] objects geojson.GeometryCollection object geojson.FeatureCollection object shapely.GeometryCollection object list of [[vertices], …]
kwargs (dictionary) – keyword arguments passed to plotutil.plot_shapefile()
- Return type:
matplotlib.Collection object
- plot_timeseries(ts, travel_time=None, **kwargs)[source]
Plot MODPATH 6 or 7 timeseries. Incompatible with MODFLOW 6 PRT.
- Parameters:
ts (list of recarrays or dataframes, or a single recarray or dataframe) – Particle timeseries data. If a list of recarrays or dataframes, each must contain the path of only a single particle. If just one recarray or dataframe, it should contain the paths of all particles. Timeseries data returned from TimeseriesFile.get_data() or get_alldata() can be passed directly as this argument. Data columns should be ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’ at minimum. Additional columns are ignored. The ‘particleid’ column must be unique to each particle path.
travel_time (float or str) – Travel time selection. If a float, then pathlines with total time less than or equal to the given value are plotted. If a string, the value must be a comparison operator, then a time value. Valid operators are <=, <, ==, >=, and >. For example, to filter pathlines with less than 10000 units of total time traveled, use ‘< 10000’. (Default is None.)
kwargs (dict) – Explicitly supported kwargs are layer, ax, colors. Any remaining kwargs are passed into the LineCollection constructor. If layer=’all’, pathlines are shown for all layers.
- Returns:
lc – The pathlines added to the plot.
- Return type:
- 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