pytopomap.plot
Created on Wed Jun 2 16:16:39 2021
@author: peruzzetto
Functions
|
Plot topography with hillshading. |
|
plt.imshow data with some pre-processing. |
|
Plot array data on topo. |
|
Plot and save maps of simulations outputs at successive time steps |
Module Contents
- pytopomap.plot.plot_topo(z: numpy.ndarray, x: numpy.ndarray, y: numpy.ndarray, contour_step: float = None, nlevels: int = None, level_min: float = None, step_contour_bold: float | str = 'auto', contour_labels_properties: dict = None, label_contour: bool = True, contour_label_effect: list = None, axe: matplotlib.axes._axes.Axes = None, vert_exag: float = 1.0, ndv: int | float = -9999, uniform_grey: str = 'auto', contours_prop: dict = None, contours_bold_prop: dict = None, figsize: tuple[float] = None, interpolation: str = None, sea_level: int | float = 0, sea_color: str = None, alpha: float = 1.0, azdeg: int | float = 315, altdeg: int | float = 45) matplotlib.axes._axes.Axes
Plot topography with hillshading.
- Parameters:
z (np.ndarray) – 2D array of elevation values.
x (np.ndarray) – 1D array of X coordinates.
y (np.ndarray) – 1D array of Y coordinates.
contour_step (float, optional) – Interval between thin contour lines. Automatically determined if None. The default is None.
nlevels (TYPE, optional) – Number of contour levels to draw if “contour_step” is not set. The default is None.
level_min (float, optional) – Minimum contour level. Automatically calculated if None. The default is None.
step_contour_bold (float or str, optional) – Interval between bold contour lines. If “auto”, computed from elevation range. The default is “auto”.
contour_labels_properties (dict, optional) – Properties passed to “ax.clabel()” for contour labels. The default is None.
label_contour (bool, optional) – If True, add labels to bold contour lines. The default is True.
contour_label_effect (list, optional) – List of matplotlib.patheffects to apply to contour labels. The default is None.
axe (matplotlib.axes._axes.Axes, optional) – Existing axes object to draw the plot on. The default is None.
vert_exag (float, optional) – Vertical exaggeration factor for hillshading. The default is 1.
ndv (int or float, optional) – No-data value in the elevation array. The default is -9999.
uniform_grey (str, optional) – If “auto”, use auto_uniform_grey to compute the hillshading. The default is “auto”.
contours_prop (dict, optional) – Properties for thin contour lines. The default is “auto”.
contours_bold_prop (dict, optional) – Properties for bold contour lines. The default is “auto”.
figsize (tuple[float], optional) – Figure size (width, height) if a new figure is created. The default is None.
interpolation (str, optional) – Interpolation method for “imshow”. The default is None.
sea_level (int or float, optional) – Sea level threshold for optional sea overlay. The default is 0.
sea_color (str, optional) – Color used to fill areas below sea level. If None, no sea mask is applied. The default is None.
alpha (float, optional) – Transparency for the hillshading layer. The default is 1.
azdeg (int or float, optional) – Azimuth angle for light source (degrees from North). The default is 315.
altdeg (int or float, optional) – Altitude angle for light source (degrees above horizon). The default is 45.
- Returns:
axe – Axes object containing the plotted topography.
- Return type:
matplotlib.axes._axes.Axes
- pytopomap.plot.plot_imshow(x: numpy.ndarray, y: numpy.ndarray, data: numpy.ndarray, axe: matplotlib.axes._axes.Axes = None, figsize: tuple[float] = None, cmap: str = None, minval: int | float = None, maxval: int | float = None, vmin: float = None, vmax: float = None, alpha: float = 1.0, minval_abs: float = None, cmap_intervals: tuple[int] | tuple[float] = None, unique_values: bool = False, extend_cc: str = 'max', plot_colorbar: bool = True, axecc: matplotlib.axes._axes.Axes = None, colorbar_kwargs: dict = None, aspect: str | float = None) matplotlib.axes._axes.Axes
plt.imshow data with some pre-processing.
- Parameters:
x (np.ndarray) – 1D array of X coordinates.
y (np.ndarray) – 1D array of Y coordinates.
data (np.ndarray) – 2D array of data values.
axe (matplotlib.axes._axes.Axes, optional) – Existing axes object to draw the plot on. The default is None.
figsize (tuple[float], optional) – Figure size (width, height) if a new figure is created. The default is None.
cmap (str, optional) – Name of the colormap to use. If None, use “hot_r” or “seismic”. The default is None.
minval (int or float, optional) – Minimum value to display. The default is None.
maxval (int or float, optional) – Maximum value to display. The default is None.
vmin (float, optional) – Alias for minval. The default is None.
vmax (float, optional) – Alias for maxval. The default is None.
alpha (float, optional) – Transparency for the data layer. The default is 1.
minval_abs (float, optional) – If set, masks values with absolute magnitude below this threshold. The default is None.
cmap_intervals (tuple of int or float, optional) – Explicit color intervals for categorical or segmented color mapping. The default is None.
unique_values (bool, optional) – If True, use discrete colormap with ticks corresponding to unique values. The default is False.
extend_cc (str, optional) – Behavior of colorbar outside bounds, can be “neither”, “min”, “max”, “both”. The default is “max”.
plot_colorbar (bool, optional) – Whether to add a colorbar. The default is True.
axecc (matplotlib.axes._axes.Axes, optional) – Axes object for the colorbar. If None, colorbar is placed automatically. The default is None.
colorbar_kwargs (dict, optional) – Additional keyword arguments passed to “figure.colorbar”.
aspect (str or float, optional) – Aspect ratio of the image. Can be “equal”, “auto”, or a numeric value.
- Returns:
axe – Axes object with the image and optional colorbar.
- Return type:
matplotlib.axes._axes.Axes
- pytopomap.plot.plot_data_on_topo(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, data: numpy.ndarray, axe: matplotlib.axes._axes.Axes = None, figsize: tuple[float] = None, cmap: str = None, minval: int | float = None, maxval: int | float = None, vmin: float = None, vmax: float = None, minval_abs: float = None, cmap_intervals: tuple[int] | tuple[float] = None, unique_values: bool = False, extend_cc: str = 'max', topo_kwargs: dict = None, alpha: float = 1.0, plot_colorbar: bool = True, axecc: matplotlib.axes._axes.Axes = None, colorbar_kwargs: dict = None, mask: numpy.ndarray = None, alpha_mask: float = None, color_mask: str = 'k', xlims: int | float = None, ylims: int | float = None) matplotlib.axes._axes.Axes
Plot array data on topo.
- Parameters:
x (np.ndarray) – 1D array of X coordinates.
y (np.ndarray) – 1D array of Y coordinates.
z (np.ndarray) – 2D array of elevation values.
data (np.ndarray) – 2D array of data values.
axe (matplotlib.axes._axes.Axes, optional) – Existing axes object to draw the plot on. The default is None.
figsize (tuple[float], optional) – Figure size (width, height) if a new figure is created. The default is None.
cmap (str, optional) – Name of the colormap to use. If None, use “hot_r” or “seismic”. The default is None.
minval (int or float, optional) – Minimum value to display. The default is None.
maxval (int or float, optional) – Maximum value to display. The default is None.
vmin (float, optional) – Alias for minval. The default is None.
vmax (float, optional) – Alias for maxval. The default is None.
minval_abs (float, optional) – If set, masks values with absolute magnitude below this threshold. The default is None.
cmap_intervals (tuple of int or float, optional) – Explicit color intervals for categorical or segmented color mapping. The default is None.
unique_values (bool, optional) – If True, use discrete colormap with ticks corresponding to unique values. The default is False.
extend_cc (str, optional) – Behavior of colorbar outside bounds, can be “neither”, “min”, “max”, “both”. The default is “max”.
topo_kwargs (dict, optional) – Additional keyword arguments passed to “plot_topo”. The default is None.
alpha (float, optional) – Transparency for the data layer. The default is 1.
plot_colorbar (bool, optional) – Whether to add a colorbar. The default is True.
axecc (matplotlib.axes._axes.Axes, optional) – Axes object for the colorbar. If None, colorbar is placed automatically. The default is None.
colorbar_kwargs (dict, optional) – Additional keyword arguments passed to “figure.colorbar”.
mask (np.ndarray, optional) – Binary 2D array of same shape as “data”. Used to overlay a mask. Masked regions are displayed with “color_mask”. The default is None.
alpha_mask (float, optional) – Transparency of the mask overlay. The default is None (fully opaque).
color_mask (str, optional) – Color used to draw the mask overlay. The default is “k”.
xlims (tuple of float, optional) – X-axis display limits (min, max). If None, auto-scaled. The default is None.
ylims (tuple of float, optional) – Y-axis display limits (min, max). If None, auto-scaled. The default is None.
- Returns:
axe – The axes object containing the final plot.
- Return type:
matplotlib.axes._axes.Axes
- pytopomap.plot.plot_maps(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, data: numpy.ndarray, t: numpy.ndarray, file_name: str = None, folder_out: str = None, figsize: tuple[float] = None, dpi: int = None, fmt: str = 'png', sup_plt_fn=None, sup_plt_fn_args=None, **kwargs) None
Plot and save maps of simulations outputs at successive time steps
- Parameters:
x (np.ndarray) – 1D array of X coordinates.
y (np.ndarray) – 1D array of Y coordinates.
z (np.ndarray) – 2D array of elevation values.
data (np.ndarray) – 2D array of data values.
t (np.ndarray) – List time steps, same length as the third dimension of “data”.
file_name (str, optional) – Base name for the output image files. The default is None.
folder_out (str, optional) – Path to the output folder. If not provides, figures are not saved. The default is None.
figsize (tuple[float], optional) – Size of each figure (width, height). The default is None.
dpi (int, optional) – Resolution for saved figures. Only used if “folder_out” is set. The default is None.
fmt (str, optional) – File format for saving figures. Default is “png”.
sup_plt_fn (callable, optional) – A custom function to apply additional plotting on the axes. The default is None.
sup_plt_fn_args (dict, optional) – Arguments to pass to “sup_plt_fn”. The default is None.
**kwargs (dict) – Additional keyword arguments passed to “plot_data_on_topo”.