geodata.plot.heatmap#
- geodata.plot.heatmap(ds: xarray.DataArray, t: int | str | None = None, agg_method: ReductionType = 'mean', shape: geopandas.GeoSeries | None = None, shape_width: float = 0.5, shape_color: str = 'black', map_type: Literal['contour', 'colormesh'] = 'colormesh', cmap: str = 'bone_r', figsize: tuple[float, float] = (10.0, 6.0), title: str | None = None, title_size: float = 12, grid: bool = True, return_fig: bool = False, **kwargs) matplotlib.pyplot.Figure | None#
Take an xarray.DataArray and a time index or string, plot contour/colormesh map for its values.
- Parameters:
ds (xr.DataArray) – The target DataArray object.
t (Optional[Union[int, str]]) – Target timestamp. This could either a numeric time index, or a time string from the xarray.DataArray time dimension.
agg_method (Literal["mean", "sum"]) – Aggregation method in the time dimension. This is used if t was not not provided. Options can either be mean aggregation or sum aggregation.
shape (geopandas.GeoSeries) – Shapes to be plotted over the raster.
shape_width (float) – Width of lines for plotting shapes. 0.5 by default.
shape_color (str) – Color of the shape line. Black by default.
map_type (Literal["contour", "colormesh"]) – Map type. This can either be “contour” or “colormesh”.
cmap (str) – The color of the heat map, select one from matplotlib.pyplot.colormaps.
figsize (tuple) – The size of the plot.
title (Optional[str]) – The title of the result plot. Optional. If not provided, the title will be automatically generated.
title_size (float) – The size of the title of the result plot. 12 by default.
coastlines (bool) – Whether to add coast lines to the plot, True by default.
grid (bool) – Whether to add grid lines to the plot, True by default.
return_fig (bool) – Whether to return the plt.Figure object. True by default
**kwargs – Additional arguments for xarray.DataArray.plot.pcolormesh or xarray.DataArray.plot.contourf, depending on selected map_type.
- Returns:
The figure object if return_fig is True.
- Return type:
Optional[plt.Figure]
- Raises:
ValueError – If the map type is not supported.