geomappy.plotting.raster.plot_raster
- geomappy.plotting.raster.plot_raster(m: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], *, ax: Axes | None = None, bins: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, norm: Normalize | None = None, vmin: float | None = None, vmax: float | None = None, extend: Literal['neither', 'both', 'min', 'max'] | None = None, cmap: str | Colormap | None = None, nan_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, legend: str | LegendCreator | None = 'colorbar', legend_ax: Axes | None = None, **kwargs) tuple[AxesImage, Colorbar | Legend | None]
Plot a 2D scalar or 3D RGB(A) raster.
- Parameters:
m (array_like) – Input array. 2D for scalar values, 3D for RGB(A) data in the last dimension.
ax (
matplotlib.axes.Axes, optional) – Axes to draw the plot. If not provided, a new figure and axes are created.bins (array_like, optional) – Bins for discretizing continuous data. Mutually exclusive with norm and vmin/vmax.
norm (
matplotlib.colors.Normalize, optional) – Normalizer for continuous data. Ignored if bins are provided.vmin (float, optional) – Min and max values for the colormap. Ignored if bins or norm are provided.
vmax (float, optional) – Min and max values for the colormap. Ignored if bins or norm are provided.
extend ({'neither', 'min', 'max', 'both'}, optional) – Colorbar extensions. Determined automatically if None.
cmap (str or
matplotlib.colors.Colormap, optional) – Colormap to use for scalar data.nan_color (ColorType, optional) – Color for NaN values. Default is white.
legend ({'colorbar', 'legend', None}, optional) – Type of legend to draw. Default is ‘colorbar’.
legend_ax (
matplotlib.axes.Axes, optional) – Axes for the legend. Created automatically if not provided.**kwargs – Additional keyword arguments passed to
matplotlib.pyplot.imshow().
- Returns:
im (
matplotlib.image.AxesImage) – The image object.legend (
matplotlib.legend.Legend,matplotlib.colorbar.Colorbar, or None) – The legend object.
Notes
When plotting on a
cartopy.mpl.geoaxes.GeoAxes, provide extent and transform in kwargs if the raster does not perfectly align with the projection. For boolean or 2-class data, the function internally callsplot_classified_raster().