landlab.plot.imshow¶
Methods to plot data defined on Landlab grids.
Plotting functions¶
|
Prepare a map view of data over all nodes or cells in the grid. |
|
Map view of grid data over all grid cells. |
|
Prepare a map view of data over all nodes in the grid. |
- class ModelGridPlotterMixIn[source]¶
Bases:
object
MixIn that provides plotting functionality.
Inhert from this class to provide a ModelDataFields object with the method function,
imshow
, that plots a data field.- __init__()¶
- __new__(**kwargs)¶
- imshow_grid(grid, values, **kwds)[source]¶
Prepare a map view of data over all nodes or cells in the grid.
Data is plotted as colored cells. If at=’node’, the surrounding cell is shaded with the value at the node at its center. If at=’cell’, the cell is shaded with its own value. Outer edges of perimeter cells are extrapolated. Closed elements are colored uniformly (default black, overridden with kwd ‘color_for_closed’); other open boundary nodes get their actual values.
values can be a field name, a regular array, or a masked array. If a masked array is provided, masked entries will be treated as if they were Landlab BC_NODE_IS_CLOSED. Used together with the color_for_closed=None keyword (i.e., “transparent”), this can allow for construction of overlay layers in a figure (e.g., only defining values in a river network, and overlaying it on another landscape).
Use matplotlib functions like xlim, ylim to modify your plot after calling
imshow_grid
, as desired.This function happily works with both regular and irregular grids.
- Parameters:
grid (ModelGrid) – Grid containing the field to plot, or describing the geometry of the provided array.
values (array_like, masked_array, or str) – Node or cell values, or a field name as a string from which to draw the data.
at (str, {'node', 'cell'}) – Tells plotter where values are defined.
plot_name (str, optional) – String to put as the plot title.
var_name (str, optional) – Variable name, to use as a colorbar label.
var_units (str, optional) – Units for the variable being plotted, for the colorbar.
grid_units (tuple of str, optional) – Units for y, and x dimensions. If None, component will look to the gri property axis_units for this information. If no units are specified there, no entry is made.
symmetric_cbar (bool) – Make the colormap symetric about 0.
cmap (str) – Name of a colormap
alpha (array-like or scalar or None, optional) – Set the transparency.
limits (tuple of float) – Minimum and maximum of the colorbar.
vmin (floats) – Alternatives to limits.
vmax (floats) – Alternatives to limits.
allow_colorbar (bool) – If True, include the colorbar.
colorbar_label (str or None) – The string with which to label the colorbar.
norm (matplotlib.colors.Normalize) – The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.
shrink (float) – Fraction by which to shrink the colorbar.
color_for_closed (str or None) – Color to use for closed elements (default ‘black’). If None, closed (or masked) elements will be transparent.
color_for_background (color str or other color declaration, or None) – Color to use for closed elements (default None). If None, the background will be transparent, and appear white.
show_elements (bool) – If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).
output (None, string, or bool) – If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.
- imshow_grid_at_cell(grid, values, **kwds)[source]¶
Map view of grid data over all grid cells.
Prepares a map view of data over all cells in the grid. Method can take any of the same
**kwds
asimshow_grid_at_node
.- Parameters:
grid (ModelGrid) – Grid containing the field to plot, or describing the geometry of the provided array.
values (array_like, masked_array, or str) – Values at the cells on the grid. Alternatively, can be a field name (string) from which to draw the data from the grid.
plot_name (str, optional) – String to put as the plot title.
var_name (str, optional) – Variable name, to use as a colorbar label.
var_units (str, optional) – Units for the variable being plotted, for the colorbar.
grid_units (tuple of str, optional) – Units for y, and x dimensions. If None, component will look to the gri property axis_units for this information. If no units are specified there, no entry is made.
symmetric_cbar (bool) – Make the colormap symetric about 0.
cmap (str) – Name of a colormap
limits (tuple of float) – Minimum and maximum of the colorbar.
vmin (floats) – Alternatives to limits.
vmax (floats) – Alternatives to limits.
allow_colorbar (bool) – If True, include the colorbar.
colorbar_label (str or None) – The string with which to label the colorbar.
norm (matplotlib.colors.Normalize) – The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.
shrink (float) – Fraction by which to shrink the colorbar.
color_for_closed (str or None) – Color to use for closed elements (default ‘black’). If None, closed (or masked) elements will be transparent.
color_for_background (color str or other color declaration, or None) – Color to use for closed elements (default None). If None, the background will be transparent, and appear white.
show_elements (bool) – If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).
output (None, string, or bool) – If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.
- Raises:
ValueError – If input grid is not uniform rectilinear.
- imshow_grid_at_node(grid, values, **kwds)[source]¶
Prepare a map view of data over all nodes in the grid. Data is plotted as cells shaded with the value at the node at its center. Outer edges of perimeter cells are extrapolated. Closed elements are colored uniformly (default black, overridden with kwd ‘color_for_closed’); other open boundary nodes get their actual values.
values can be a field name, a regular array, or a masked array. If a masked array is provided, masked entries will be treated as if they were Landlab BC_NODE_IS_CLOSED. Used together with the color_at_closed=None keyword (i.e., “transparent”), this can allow for construction of overlay layers in a figure (e.g., only defining values in a river network, and overlaying it on another landscape).
Use matplotlib functions like xlim, ylim to modify your plot after calling
imshow_grid
, as desired.Node coordinates are printed when a mouse button is pressed on a cell in the plot.
This function happily works with both regular and irregular grids.
- Parameters:
grid (ModelGrid) – Grid containing the field to plot, or describing the geometry of the provided array.
values (array_like, masked_array, or str) – Node values, or a field name as a string from which to draw the data.
plot_name (str, optional) – String to put as the plot title.
var_name (str, optional) – Variable name, to use as a colorbar label.
var_units (str, optional) – Units for the variable being plotted, for the colorbar.
grid_units (tuple of str, optional) – Units for y, and x dimensions. If None, component will look to the grid property axis_units for this information. If no units are specified there, no entry is made.
symmetric_cbar (bool) – Make the colormap symetric about 0.
cmap (str) – Name of a colormap
limits (tuple of float) – Minimum and maximum of the colorbar.
vmin (floats) – Alternatives to limits.
vmax (floats) – Alternatives to limits.
allow_colorbar (bool) – If True, include the colorbar.
colorbar_label (str or None) – The string with which to label the colorbar.
norm (matplotlib.colors.Normalize) – The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.
shrink (float) – Fraction by which to shrink the colorbar.
color_for_closed (str or None) – Color to use for closed nodes (default ‘black’). If None, closed (or masked) nodes will be transparent.
color_for_background (color str or other color declaration, or None) – Color to use for closed elements (default None). If None, the background will be transparent, and appear white.
show_elements (bool) – If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).
output (None, string, or bool) – If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.