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, **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

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

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_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_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 name 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 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