landlab.plot.imshowhs

Methods to plot data defined on Landlab grids.

Plotting functions

imshowhs_grid(grid, values, **kwds)

Prepare a map view of data over all nodes in the grid using a hillshade topography map in the background.

imshowhs_grid_at_node(grid, values, **kwds)

Prepare a map view of data over all nodes in the grid using a hillshade topography map in the background.

imshowhs_grid(grid, values, **kwds)[source]

Prepare a map view of data over all nodes in the grid using a hillshade topography map in the background.

Data are 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 (with the color being controlled by the color_for_closed keyword); 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 are treated as if they were landlab CLOSED nodes. If closed nodes are also set to be transparent (i.e. color_for_closed=None), this can allow for the construction of overlying layers in a figure (e.g., only defining values in a river network, and then overlaying it on another landscape).

Use matplotlib functions like xlim, ylim to modify your plot after calling imshowhs_grid, as desired.

Node coordinates are printed when a mouse button is pressed on a cell in the plot.

Note

For now, this function only works with RasterModelGrid.

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_name_two (str, optional) – Variable name of second layer, 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 symmetric 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.

  • norm (matplotlib.colors.Normalize) – The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.

  • ticks_km (bool, optional) – Display ticks in km instead of m

  • allow_colorbar (bool) – If True, include the colorbar.

  • shrink (float) – Fraction by which to shrink the colorbar.

  • color_for_closed (str or None) – Color to use for closed nodes (default None). If None, (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.

  • 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 str, 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.

  • fontweight_xlabel (str, optional) – Weight of x label. The default is ‘bold’.

  • fontweight_ylabel (str, optional) – Weight of y label. The default is ‘bold’.

  • plot_type ({"DEM", "Hillshade", "Drape1", "Drape2"}, optional) –

    The type of plot that will be plotted.

    • ’DEM’: Display a digital elevation map underlain by a shaded relief, based on the same DEM (‘topographic__elevation’)

    • ’Hillshade’: Display the shaded relief, of the provided DEM (‘topographic__elevation’)

    • ’Drape1’: Display any kind of provided layer on top of a shaded relief provided in the ‘topographic__elevation’ field

    • ’Drape2’: Display two layers on top of a shaded relief provided in the ‘topographic__elevation’ field

    The default is “DEM”.

  • drape1 (array_like, masked_array) – Node values to plot on top of a hillshade map. The default is None.

  • drape2 (array_like, masked_array) – Node values to plot on top of drape1 and a hillshade map. The default is None.

  • cmap2 (str) – Name of a colormap for drape 2. The default is None.

  • vertical_exa (float, optional) – Vertical exaggeration of hillshade map. The default is None.

  • azdeg (float, optional) – Azimuth of the light source. The default is 315.

  • altdeg (float, optional) – Elevation of the light source. The default is 65.

  • thres_drape1 (float, optional) – Threshold below which drape1 is made transparent. The default is None.

  • alpha (float (0-1), optional) – Transparency of DEM/Drape1 . The default is None.

  • thres_drape2 (float, optional) – Threshold below which drape2 is made transparent. The default is None.

  • alpha2 (float (0-1), optional) – Transparency of Drape2 . The default is None.

  • add_double_colorbar (bool, optional) – Add a double colorbar when two drapes are plotted. The default is False.

  • plt_contour (bool, optional) – Add contour lines to elevation plot. The default is False.

  • contour_nb (int, optional) – Number of contour lines. The default is 50.

  • default_fontsize (float, optional) – Default font size for plot labels. The default is 10.

  • cbar_height (percentage, optional) – Height of colorbar as a percentage of the figure. The default is 5%.

  • cbar_width (percentage, optional) – Width of colorbar in percentage of figure. The default is 30%.

  • cbar_or (str, optional) – Orientation of colorbar. The default is “horizontal”.

  • cbar_loc (str, optional) – Location of colorbar. The default is “lower right”.

  • bbox_to_anchor (vector, optional) – Bounding box to anchor. The default is (0, 0, 1, 1).

  • cbar_ticks_position (str, optional) – location of colorbar ticks (below or on top of the colorbar). The default is “top”.

  • cbar_ticks_position2 (str, optional) – location of colorbar ticks for colorbar of Drape2 (below or on top of the colorbar). The default is “bottom”.

  • colorbar_label_y (float, optional) – location of colorbar label with respect to the colorbar in y direction. The default is -40.

  • colorbar_label_x (float , optional) – location of colorbar label with respect to the colorbar in x direction. The default is 0.5.

  • cbar_tick_size (float, optional) – Colorbar tick size. The default is 10.

  • cbar_label_color (str, optional) – Colorbar tick color. The default is ‘black’.

  • cbar_label_fontweight (str, optional) – Colorbar font weight. The default is ‘bold’.

  • add_label_bbox (bool, optional) – Add a bbox surrounding the colorbar label. The default is False.

  • y_label_offSet_var_1 (float, optional) – Offset of ylabel on colorbar of first variable in plot with two overlaying plots. The default is 3.0.

  • y_label_offSet_var_2 (float, optional) – Offset of ylabel on colorbar of first variable in plot with two overlaying plots. The default is -1.25.

Returns:

Axis of the plot if output keyword is True.

Return type:

ax

imshowhs_grid_at_node(grid, values, **kwds)[source]

Prepare a map view of data over all nodes in the grid using a hillshade topography map in the background.

Data are 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 (with the color being controlled by the color_for_closed keyword); 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 are treated as if they were landlab CLOSED nodes. If closed nodes are also set to be transparent (i.e. color_for_closed=None), this can allow for the construction of overlying layers in a figure (e.g., only defining values in a river network, and then overlaying it on another landscape).

Use matplotlib functions like xlim, ylim to modify your plot after calling imshowhs_grid, as desired.

Node coordinates are printed when a mouse button is pressed on a cell in the plot.

Note

For now, this function only works with RasterModelGrid.

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_name_two (str, optional) – Variable name of second layer, 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 symmetric 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.

  • norm (matplotlib.colors.Normalize) – The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.

  • ticks_km (bool, optional) – Display ticks in km instead of m

  • allow_colorbar (bool) – If True, include the colorbar.

  • shrink (float) – Fraction by which to shrink the colorbar.

  • color_for_closed (str or None) – Color to use for closed nodes (default None). If None, (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.

  • 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 str, 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.

  • fontweight_xlabel (str, optional) – Weight of x label. The default is ‘bold’.

  • fontweight_ylabel (str, optional) – Weight of y label. The default is ‘bold’.

  • plot_type ({"DEM", "Hillshade", "Drape1", "Drape2"}, optional) –

    The type of plot that will be plotted.

    • ’DEM’ (the default): Display a digital elevation map underlain by a shaded relief, based on the same DEM (‘topographic__elevation’)

    • ’Hillshade’: Display the shaded relief, of the provided DEM (‘topographic__elevation’)

    • ’Drape1’: Display any kind of provided layer on top of a shaded relief provided in the ‘topographic__elevation’ field

    • ’Drape2’: Display two layers on top of a shaded relief provided in the ‘topographic__elevation’ field

    The default is “DEM”.

  • drape1 (array_like, masked_array) – Node values to plot on top of a hillshade map. The default is None.

  • drape2 (array_like, masked_array) – Node values to plot on top of drape1 and a hillshade map. The default is None.

  • cmap2 (str) – Name of a colormap for drape 2. The default is None.

  • vertical_exa (float, optional) – Vertical exaggeration of hillshade map. The default is None.

  • azdeg (float, optional) – Azimuth of the light source. The default is 315.

  • altdeg (float, optional) – Elevation of the light source. The default is 65.

  • thres_drape1 (float, optional) – Threshold below which drape1 is made transparent. The default is None.

  • alpha (float (0-1), optional) – Transparency of DEM/Drape1 . The default is None.

  • thres_drape2 (float, optional) – Threshold below which drape2 is made transparent. The default is None.

  • alpha2 (float (0-1), optional) – Transparency of Drape2 . The default is None.

  • add_double_colorbar (bool, optional) – Add a double colorbar when two drapes are plotted. The default is False.

  • plt_contour (bool, optional) – Add contour lines to elevation plot. The default is False.

  • contour_nb (int, optional) – Number of contour lines. The default is 50.

  • default_fontsize (float, optional) – Default font size for plot labels. The default is 10.

  • cbar_height (percentage, optional) – Height of colorbar as a percentage of the figure. The default is 5%.

  • cbar_width (percentage, optional) – Width of colorbar in percentage of figure. The default is 30%.

  • cbar_or (str, optional) – Orientation of colorbar. The default is “horizontal”.

  • cbar_loc (str, optional) – Location of colorbar. The default is “lower right”.

  • bbox_to_anchor (vector, optional) – Bounding box to anchor. The default is (0, 0, 1, 1).

  • cbar_ticks_position (str, optional) – Location of colorbar ticks (below or on top of the colorbar). The default is “top”.

  • cbar_ticks_position2 (str, optional) – Location of colorbar ticks for colorbar of Drape2 (below or on top of the colorbar). The default is “bottom”.

  • colorbar_label_y (float, optional) – Location of colorbar label with respect to the colorbar in y direction. The default is -40.

  • colorbar_label_x (float , optional) – Location of colorbar label with respect to the colorbar in x direction. The default is 0.5.

  • cbar_tick_size (float, optional) – Colorbar tick size. The default is 10.

  • cbar_label_color (str, optional) – Colorbar tick color. The default is ‘black’.

  • cbar_label_fontweight (str, optional) – Colorbar font weight. The default is ‘bold’.

  • add_label_bbox (bool, optional) – Add a bbox surrounding the colorbar label. The default is False.

  • y_label_offSet_var_1 (float, optional) – Offset of ylabel on colorbar of first variable in plot with two overlaying plots. The default is 3.0.

  • y_label_offSet_var_2 (float, optional) – Offset of ylabel on colorbar of first variable in plot with two overlaying plots. The default is -1.25.

Returns:

Axis of the plot if output keyword is True.

Return type:

ax