flopy.plot.plotutil Module¶
Module containing helper functions for plotting model data using ModelMap and ModelCrossSection. Functions for plotting shapefiles are also included.

class
flopy.plot.plotutil.
SwiConcentration
(model=None, botm=None, istrat=1, nu=None)¶ The binary_header class is a class to create headers for MODFLOW binary files

calc_conc
(zeta, layer=None)¶ Calculate concentrations for a given time step using passed zeta.
Parameters: zeta : dictionary of numpy arrays
Dictionary of zeta results. zeta keys are zerobased zeta surfaces.
layer : int
Concentration will be calculated for the specified layer. If layer is None, then the concentration will be calculated for all layers. (default is None).
Returns: conc : numpy array
Calculated concentration.
Examples
>>> import flopy >>> m = flopy.modflow.Modflow.load('test') >>> c = flopy.plot.SwiConcentration(model=m) >>> conc = c.calc_conc(z, layer=0)


flopy.plot.plotutil.
cell_value_points
(pts, xedge, yedge, vdata)¶ Intersect a list of polyline vertices with a rectilinear MODFLOW grid. Vertices at the intersection of the polyline with the grid cell edges is returned. Optionally the original polyline vertices are returned.
Parameters: pts : list
A list of x, y points and polyline length to extract defining the vertices of a polyline that
xedge : numpy.ndarray
xcoordinate of the edge of each MODFLOW column. The shape of xedge is (NCOL + 1). If xedge is not a numpy.ndarray it is converted to a numpy.ndarray.
yedge : numpy.ndarray
ycoordinate of the edge of each MODFLOW row. The shape of yedge is (NROW + 1). If yedge is not a numpy.ndarray it is converted to a numpy.ndarray.
vdata : numpy.ndarray
Data (i.e., head, hk, etc.) for a rectilinear MODFLOW model grid. The shape of vdata is (NROW, NCOL). If vdata is not a numpy.ndarray it is converted to a numpy.ndarray.
Returns: vcell : numpy.ndarray
numpy.ndarray of of data values from the vdata numpy.ndarray at x and ycoordinate locations in pts.
Examples
>>> import flopy >>> vcell = flopy.plotutil.cell_value_points(xpts, xedge, yedge, head[0, :, :])

flopy.plot.plotutil.
centered_specific_discharge
(Qx, Qy, Qz, delr, delc, sat_thk)¶ Using the MODFLOW discharge, calculate the cell centered specific discharge by dividing by the flow width and then averaging to the cell center.
Parameters: Qx : numpy.ndarray
MODFLOW ‘flow right face’
Qy : numpy.ndarray
MODFLOW ‘flow front face’. The sign on this array will be flipped by this function so that the y axis is positive to north.
Qz : numpy.ndarray
MODFLOW ‘flow lower face’. The sign on this array will be flipped by this function so that the z axis is positive in the upward direction.
delr : numpy.ndarray
MODFLOW delr array
delc : numpy.ndarray
MODFLOW delc array
sat_thk : numpy.ndarray
Saturated thickness for each cell
Returns: (qx, qy, qz) : tuple of numpy.ndarrays
Specific discharge arrays that have been interpolated to cell centers.

flopy.plot.plotutil.
cvfd_to_patch_collection
(verts, iverts)¶ Create a patch collection from control volume vertices and incidence list
Parameters: verts : ndarray
2d array of x and y points.
iverts : list of lists
should be of len(ncells) with a list of vertex numbers for each cell

flopy.plot.plotutil.
findrowcolumn
(pt, xedge, yedge)¶ Find the MODFLOW cell containing the x and y point provided.
Parameters: pt : list or tuple
A list or tuple containing a x and y coordinate
xedge : numpy.ndarray
xcoordinate of the edge of each MODFLOW column. xedge is dimensioned to NCOL + 1. If xedge is not a numpy.ndarray it is converted to a numpy.ndarray.
yedge : numpy.ndarray
ycoordinate of the edge of each MODFLOW row. yedge is dimensioned to NROW + 1. If yedge is not a numpy.ndarray it is converted to a numpy.ndarray.
Returns: irow, jcol : int
Row and column location containing x and y point passed to function.
Examples
>>> import flopy >>> irow, jcol = flopy.plotutil.findrowcolumn(pt, xedge, yedge)

flopy.plot.plotutil.
line_intersect_grid
(ptsin, xedge, yedge, returnvertices=False)¶ Intersect a list of polyline vertices with a rectilinear MODFLOW grid. Vertices at the intersection of the polyline with the grid cell edges is returned. Optionally the original polyline vertices are returned.
Parameters: ptsin : list
A list of x, y points defining the vertices of a polyline that will be intersected with the rectilinear MODFLOW grid
xedge : numpy.ndarray
xcoordinate of the edge of each MODFLOW column. xedge is dimensioned to NCOL + 1. If xedge is not a numpy.ndarray it is converted to a numpy.ndarray.
yedge : numpy.ndarray
ycoordinate of the edge of each MODFLOW row. yedge is dimensioned to NROW + 1. If yedge is not a numpy.ndarray it is converted to a numpy.ndarray.
returnvertices: bool
Return the original polyline vertices in the list of numpy.ndarray containing vertices resulting from intersection of the provided polygon and the MODFLOW model grid if returnvertices=True. (default is False).
Returns: (x, y, dlen) : numpy.ndarray of tuples
numpy.ndarray of tuples containing the x, y, and segment length of the intersection of the provided polyline with the rectilinear MODFLOW grid.
Examples
>>> import flopy >>> ptsout = flopy.plotutil.line_intersect_grid(ptsin, xedge, yedge)

flopy.plot.plotutil.
plot_cvfd
(verts, iverts, ax=None, layer=0, cmap='Dark2', edgecolor='scaled', facecolor='scaled', a=None, masked_values=None, **kwargs)¶ Generic function for plotting a control volume finite difference grid of information.
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
ax : matplotlib.pylot axis
matplotlib.pyplot axis instance. Default is None
layer : int
layer to extract. Used in combination to the optional ncpl parameter. Default is 0
linewidth : float
Width of all lines. (default is 1)
cmap : string
Name of colormap to use for polygon shading (default is ‘Dark2’)
edgecolor : string
Color name. (Default is ‘scaled’ to scale the edge colors.)
facecolor : string
Color name. (Default is ‘scaled’ to scale the face colors.)
a : numpy.ndarray
Array to plot.
masked_values : iterable of floats, ints
Values to mask.
kwargs : dictionary
Keyword arguments that are passed to PatchCollection.set(
**kwargs
). Some common kwargs would be ‘linewidths’, ‘linestyles’, ‘alpha’, etc.Returns: pc : matplotlib.collections.PatchCollection

flopy.plot.plotutil.
plot_shapefile
(shp, ax=None, radius=500.0, cmap='Dark2', edgecolor='scaled', facecolor='scaled', a=None, masked_values=None, idx=None, **kwargs)¶ Generic function for plotting a shapefile.
Parameters: shp : string
Name of the shapefile to plot.
radius : float
Radius of circle for points. (Default is 500.)
linewidth : float
Width of all lines. (default is 1)
cmap : string
Name of colormap to use for polygon shading (default is ‘Dark2’)
edgecolor : string
Color name. (Default is ‘scaled’ to scale the edge colors.)
facecolor : string
Color name. (Default is ‘scaled’ to scale the face colors.)
a : numpy.ndarray
Array to plot.
masked_values : iterable of floats, ints
Values to mask.
idx : iterable int
A list or array that contains shape numbers to include in the patch collection. Return all shapes if not specified.
kwargs : dictionary
Keyword arguments that are passed to PatchCollection.set(
**kwargs
). Some common kwargs would be ‘linewidths’, ‘linestyles’, ‘alpha’, etc.Returns: pc : matplotlib.collections.PatchCollection

flopy.plot.plotutil.
saturated_thickness
(head, top, botm, laytyp, mask_values=None)¶ Calculate the saturated thickness.
Parameters: head : numpy.ndarray
head array
top : numpy.ndarray
top array of shape (nrow, ncol)
botm : numpy.ndarray
botm array of shape (nlay, nrow, ncol)
laytyp : numpy.ndarray
confined (0) or convertible (1) of shape (nlay)
mask_values : list of floats
If head is one of these values, then set sat to top  bot
Returns: sat_thk : numpy.ndarray
Saturated thickness of shape (nlay, nrow, ncol).

flopy.plot.plotutil.
shapefile_extents
(shp)¶ Determine the extents of a shapefile
Parameters: shp : string
Name of the shapefile to convert to a PatchCollection.
Returns: extents : tuple
tuple with xmin, xmax, ymin, ymax from shapefile.
Examples
>>> import flopy >>> fshp = 'myshapefile' >>> extent = flopy.plot.plotutil.shapefile_extents(fshp)

flopy.plot.plotutil.
shapefile_get_vertices
(shp)¶ Get vertices for the features in a shapefile
Parameters: shp : string
Name of the shapefile to extract shapefile feature vertices.
Returns: vertices : list
Vertices is a list with vertices for each feature in the shapefile. Individual feature vertices are x, y tuples and contained in a list. A list with a single x, y tuple is returned for point shapefiles. A list with multiple x, y tuples is returned for polyline and polygon shapefiles.
Examples
>>> import flopy >>> fshp = 'myshapefile' >>> lines = flopy.plot.plotutil.shapefile_get_vertices(fshp)

flopy.plot.plotutil.
shapefile_to_patch_collection
(shp, radius=500.0, idx=None)¶ Create a patch collection from the shapes in a shapefile
Parameters: shp : string
Name of the shapefile to convert to a PatchCollection.
radius : float
Radius of circle for points in the shapefile. (Default is 500.)
idx : iterable int
A list or array that contains shape numbers to include in the patch collection. Return all shapes if not specified.
Returns: pc : matplotlib.collections.PatchCollection
Patch collection of shapes in the shapefile