environmentaltools.graphics.plot_presence_boundary
- environmentaltools.graphics.plot_presence_boundary(contours, mean_map, threshold=None, title=None, figsize=(10, 8), cmap='viridis', output_path=None)[source]
Visualize mean presence boundary with contours and background heatmap.
Creates a visualization showing the spatial mean map as a heatmap with overlaid contour lines indicating the presence boundary threshold.
- Parameters:
contours (list) – List of contour coordinates from mean_presence_boundary function.
mean_map (np.ndarray) – 2D array of temporal mean values for each spatial location.
threshold (float, optional) – Threshold value used to define presence boundary. If None, uses the mean of mean_map.
title (str, optional) – Plot title. If None, uses default title.
figsize (tuple, optional) – Figure size as (width, height). Default is (10, 8).
cmap (str, optional) – Colormap for the heatmap. Default is ‘viridis’.
output_path (str or Path, optional) – Path to save the figure. If None, displays the plot.
- Returns:
If output_path is provided, returns the path where figure was saved. Otherwise, displays the plot and returns None.
- Return type:
None or str
Examples
>>> from environmentaltools.spatiotemporal import indicators >>> from environmentaltools.graphics import spatiotemporal >>> import numpy as np >>> >>> # Generate sample data >>> data_cube = np.random.random((365, 50, 50)) >>> contours, mean_map = indicators.mean_presence_boundary(data_cube, threshold=0.6) >>> >>> # Visualize >>> spatiotemporal.plot_presence_boundary(contours, mean_map, threshold=0.6)