resplotlib

resplotlib.resplotclass

class resplotlib.resplotclass.Resplotclass(file_path: str | None = None)[source]

Bases: object

Resilient plotter class.

This class provides methods for plotting and exploring geospatial data. It also provides methods for setting and getting guidelines for plotting, as well as support methods for creating subplots and maps, showing and saving figures, and creating videos.

guidelines

The guidelines for plotting.

Type:

resplotlib.Guidelines

Parameters:

file_path (str, optional) – File path to project guidelines. Defaults to None.

Map(gdf: GeoDataFrame | None = None, clear_on_draw: bool = False, geoman_draw: bool = True, bounds: list | None = None, **kwargs) Map[source]

Create an interactive map.

Parameters:
  • gdf (gpd.GeoDataFrame, optional) – GeoDataFrame containing the geometries to add to the map. Defaults to None.

  • clear_on_draw (bool, optional) – Clear drawn geometries from the map when a new geometry is drawn. Defaults to False.

  • geoman_draw (bool, optional) – Use GeomanDrawControl to draw geometries on the map. Defaults to True.

  • bounds (list, optional) – Initial bounds of the map in the format [xmin, ymin, xmax, ymax]. Defaults to None.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to Map.

Returns:

The interactive map object.

Return type:

resplotlib.map.Map

basemap(crs: CRS | CRS | str | None, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Plot a basemap.

Parameters:
  • crs (pyproj.CRS, rasterio.crs.CRS, str or None) – Coordinate reference system of the basemap.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to plot_basemap.

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

close(fig, **kwargs) None[source]

Close a figure or interactive map.

Parameters:
Returns:

None

contour(da: DataArray | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Contour plot of a xarray.DataArray or xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.contour() or xugrid.plot.contour().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

contourf(da: DataArray | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Filled contour plot of a xarray.DataArray or xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.contourf() or xugrid.plot.contourf().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

explore_basemap(m: Map | Map | None = None, overwrite: bool = False, show_kwargs: bool = False, **kwargs) Map[source]

Explore a basemap in an interactive map.

Parameters:
  • m (ipyleaflet.Map, resplotlib.map.Map, optional) – The map to be used for plotting. If None, a new map will be created. Defaults to None.

  • overwrite (bool, optional) – Whether to overwrite an existing layer with the same name. Defaults to False.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to explore_basemap.

Returns:

The interactive map object.

Return type:

ipyleaflet.Map

explore_data(da: DataArray | UgridDataArray, m: Map | Map | None = None, overwrite: bool = False, show_kwargs: bool = False, **kwargs) Map[source]

Explore a xarray.DataArray or xugrid.UgridDataArray in an interactive map.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to explore.

  • m (ipyleaflet.Map, resplotlib.map.Map, optional) – The map to be used for plotting. If None, a new map will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • overwrite (bool, optional) – Whether to overwrite an existing layer with the same name. Defaults to False.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to explore_da or explore_uda.

Returns:

The interactive map object.

Return type:

ipyleaflet.Map

explore_geometries(gdf: GeoDataFrame, m: Map | Map | None = None, overwrite: bool = False, show_kwargs: bool = False, **kwargs) Map[source]

Explore a geopandas.GeoDataFrame in an interactive map.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to explore.

  • m (ipyleaflet.Map, resplotlib.map.Map, optional) – The map to be used for plotting. If None, a new map will be created. Defaults to None.

  • overwrite (bool, optional) – Whether to overwrite an existing layer with the same name. Defaults to False.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to explore_gdf.

Returns:

The interactive map object.

Return type:

ipyleaflet.Map

from_structured(da, **kwargs) UgridDataArray[source]

Convert a structured xarray.DataArray to an unstructured xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray) – The structured DataArray to convert.

  • **kwargs – Additional keyword arguments to pass to to_unstructured.

Returns:

The converted unstructured UgridDataArray.

Return type:

xugrid.UgridDataArray

geometries(gdf: GeoDataFrame, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Plot a geopandas.GeoDataFrame.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to plot_gdf.

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

get_guidelines() Guidelines[source]

Get guidelines for the Resplotclass.

Returns:

The guidelines object.

Return type:

resplotlib.Guidelines

gif(file_path_images: list[str], file_path_gif: str, fps: int = 5, **kwargs) None[source]

Create a GIF from a list of images.

Parameters:
  • file_path_images (list[str]) – List of file paths to images.

  • file_path_gif (str) – File path for the output GIF.

  • fps (int, optional) – Frames per second for the GIF. Defaults to 5.

  • **kwargs – Additional keyword arguments to pass to imageio.mimsave().

grid(da: DataArray | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Grid plot of a xarray.DataArray or xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.line() or xugrid.plot.line().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

imshow(da: DataArray | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Image plot of a xarray.DataArray or xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.imshow() or xugrid.plot.imshow().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

pcolormesh(da: DataArray | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Pseudocolor plot of a xarray.DataArray or xugrid.UgridDataArray.

Parameters:
  • da (xarray.DataArray or xugrid.UgridDataArray) – DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.pcolormesh() or xugrid.plot.pcolormesh().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

quiver(ds: Dataset, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Quiver plot of a xarray.Dataset.

Parameters:
  • ds (xarray.Dataset) – Dataset to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.quiver().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

save(fig, file_path, **kwargs) None[source]

Save a figure or interactive map to a file.

Parameters:
  • fig (matplotlib.figure.Figure or ipyleaflet.Map) – The figure or map to save.

  • file_path (str) – The file path where the figure or map should be saved.

  • **kwargs (dict, optional) – Additional keyword arguments. For matplotlib figures, tight_layout (bool, default True) controls whether to apply tight layout before saving.

Returns:

None

scatter(ds: Dataset | UgridDataArray, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Scatter plot of a xarray.Dataset or xugrid.UgridDataArray.

Parameters:
  • ds (xarray.Dataset or xugrid.UgridDataArray) – Dataset or DataArray to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.scatter() or xugrid.plot.scatter().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

set_guidelines(file_path: str | None = None) None[source]

Set guidelines for the Resplotclass.

Parameters:

file_path (str, optional) – File path to project guidelines. Defaults to None.

show(fig: Figure | Map, **kwargs) None[source]

Display a figure or interactive map.

Parameters:
  • fig (matplotlib.figure.Figure or ipyleaflet.Map) – The figure or map to display.

  • **kwargs (dict, optional) – Additional keyword arguments. For matplotlib figures, tight_layout (bool, default True) controls whether to apply tight layout before showing.

Returns:

None

show_guidelines() None[source]

Show guidelines for the Resplotclass.

streamplot(ds: Dataset, ax: Axes | None = None, style: str | None = None, extent: str | None = None, rescale_unit: str | None = None, skip: int = 1, smooth: int = 1, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, subplot_kwargs: dict | None = None, append_axes_kwargs: dict | None = None, xlabel_kwargs: dict | None = None, ylabel_kwargs: dict | None = None, title_kwargs: dict | None = None, aspect_kwargs: dict | None = None, grid_kwargs: dict | None = None, show_kwargs: bool = False, **kwargs) Axes[source]

Streamline plot of a xarray.Dataset.

Parameters:
  • ds (xarray.Dataset) – Dataset to plot.

  • ax (matplotlib.axes.Axes, optional) – The axes to be used for plotting. If None, a new figure and axes will be created. Defaults to None.

  • style (str, optional) – The style to be applied to the plot. Defaults to “default”. Set to “none” to ignore style guidelines.

  • extent (str or None, optional) – The extent to be applied to the plot. Defaults to None.

  • rescale_unit (str or None, optional) – The unit to which the data or CRS should be rescaled. If None, the rescale_unit specified in the guidelines will be used. Defaults to None.

  • skip (int, optional) – The factor by which to skip data points. Defaults to 1.

  • smooth (int, optional) – The factor by which to smooth data points. Defaults to 1.

  • xlim (tuple[float, float], optional) – The limits for the x-axis. Defaults to None.

  • ylim (tuple[float, float], optional) – The limits for the y-axis. Defaults to None.

  • subplot_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.pyplot.subplots() when creating a new figure and axes. Defaults to None.

  • append_axes_kwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes_grid1.axes_divider.make_axes_locatable.append_axes() for creating the colorbar axis. If None, no colorbar axis will be created. Defaults to None.

  • xlabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_xlabel() for formatting the x-axis label. If None, the x-axis label will be determined automatically. Defaults to None.

  • ylabel_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_ylabel() for formatting the y-axis label. If None, the y-axis label will be determined automatically. Defaults to None.

  • title_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_title() for formatting the title. If None, the title will be set to an empty string. Defaults to None.

  • aspect_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.set_aspect() for formatting the aspect ratio. If None, the aspect ratio will be set to ‘equal’. Defaults to None.

  • grid_kwargs (dict, optional) – Additional keyword arguments passed to matplotlib.axes.Axes.grid() for formatting the grid. If None, the grid will be set to visible. Defaults to None.

  • show_kwargs (bool, optional) – Whether to print the keyword arguments passed to plotting function. Defaults to False.

  • **kwargs (dict, optional) – Additional keyword arguments to pass to xarray.plot.streamplot().

Returns:

The axes object of the plot.

Return type:

matplotlib.axes.Axes

subplots(*args, **kwargs) tuple[Figure, Axes][source]

Create a figure and a set of subplots.

Parameters:
Returns:

A tuple containing the figure and axes object(s).

Return type:

tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]

to_structured(uda, **kwargs) DataArray[source]

Convert an unstructured xugrid.UgridDataArray or xugrid.UgridDataset to a structured xarray.DataArray.

Parameters:
Returns:

The converted structured DataArray.

Return type:

xarray.DataArray

video(file_path_images: list[str], file_path_video: str, fps: int = 5, **kwargs) None[source]

Create a video from a list of images.

Parameters:
  • file_path_images (list[str]) – List of file paths to images.

  • file_path_video (str) – File path for the output video.

  • fps (int, optional) – Frames per second for the video. Defaults to 5.

  • **kwargs – Additional keyword arguments to pass to cv2.VideoWriter().

resplotlib.guidelines

class resplotlib.guidelines.Guidelines[source]

Bases: Dict

This class is a dictionary that contains the plotting guidelines. It can be initialised with a dictionary or with a json file containing the guidelines.

Parameters:
  • *args – Arguments to initialise the dictionary.

  • file_path (str, optional) – Path to a json file containing the guidelines. Defaults to None.

show(open: bool = True) None[source]

Show guidelines.

Parameters:

open (bool) – Show guidelines as open or closed. Defaults to True.

resplotlib.map

class resplotlib.map.Map(**kwargs: Any)[source]

Bases: Map

A class for creating an interactive map using ipyleaflet.

drawn

A flag indicating whether geometries have been drawn on the map.

Type:

bool

style_kwargs

A dictionary containing the style options for the geometries drawn on the map.

Type:

dict

draw_control

The draw control used for drawing geometries on the map.

Type:

ipyleaflet.DrawControl or ipyleaflet.GeomanDrawControl

Parameters:
  • gdf (geopandas.GeoDataFrame, optional) – GeoDataFrame containing draw geometries to add to the map. Defaults to None.

  • clear_on_draw (bool, optional) – Clear drawn geometries from the map when a new geometry is drawn. Defaults to False.

  • geoman_draw (bool, optional) – Use GeomanDrawControl to draw geometries on the map. Defaults to True.

  • **kwargs – Additional keyword arguments to pass to ipyleaflet.Map.

clear_drawn_geometries() None[source]

Clear geometries from the map.

get_drawn_boxes(crs: str = 'EPSG:4326') GeoDataFrame[source]

Get drawn boxes from the map.

Parameters:

crs (str, optional) – Coordinate reference system to reproject the geometries to. Defaults to “EPSG:4326”.

Returns:

GeoDataFrame containing the drawn box geometries from the map.

Return type:

geopandas.GeoDataFrame

get_drawn_geometries(crs: str = 'EPSG:4326') GeoDataFrame[source]

Get drawn geometries from the map.

Parameters:

crs (str, optional) – Coordinate reference system to reproject the geometries to. Defaults to “EPSG:4326”.

Returns:

GeoDataFrame containing the drawn geometries from the map.

Return type:

geopandas.GeoDataFrame

get_drawn_lines(crs: str = 'EPSG:4326') GeoDataFrame[source]

Get drawn lines from the map.

Parameters:

crs (str, optional) – Coordinate reference system to reproject the geometries to. Defaults to “EPSG:4326”.

Returns:

GeoDataFrame containing the drawn lines from the map.

Return type:

geopandas.GeoDataFrame

get_drawn_points(crs: str = 'EPSG:4326') GeoDataFrame[source]

Get drawn points from the map.

Parameters:

crs (str, optional) – Coordinate reference system to reproject the geometries to. Defaults to “EPSG:4326”.

Returns:

GeoDataFrame containing the drawn points from the map.

Return type:

geopandas.GeoDataFrame

get_drawn_polygons(crs: str = 'EPSG:4326') GeoDataFrame[source]

Get drawn polygons from the map.

Parameters:

crs (str, optional) – Coordinate reference system to reproject the geometries to. Defaults to “EPSG:4326”.

Returns:

GeoDataFrame containing the drawn polygons from the map.

Return type:

geopandas.GeoDataFrame

get_view_bounds() tuple[float, float, float, float][source]

Get view bounds of the map.

Returns:

View bounds in the format (minx, miny, maxx, maxy).

Return type:

tuple[float, float, float, float]

get_view_zoom() int[source]

Get view zoom level of the map.

Returns:

View zoom level of the map.

Return type:

int

set_drawn_geometries(gdf: GeoDataFrame) None[source]

Set geometries to the map.

Parameters:

gdf (geopandas.GeoDataFrame) – GeoDataFrame containing the geometries to add to the map.

resplotlib.basemaps

resplotlib.basemaps.plot_basemap(crs: CRS | CRS | str | None, ax: Axes, rescale_unit: str | None = None, xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, **kwargs)[source]

Plot a basemap on a matplotlib axis.

Parameters:
  • crs (pyproj.CRS, rasterio.crs.CRS, str) – Coordinate reference system of the basemap.

  • ax (matplotlib.axes.Axes) – Axis to plot on.

  • rescale_unit (str, optional) – Unit to which to rescale the basemap. If None, rescale unit will be determined automatically. Defaults to None.

  • xlim (tuple[float, float], optional) – Limits for the x-axis. If None, limits will be determined automatically. Defaults to None.

  • ylim (tuple[float, float], optional) – Limits for the y-axis. If None, limits will be determined automatically. Defaults to None.

  • **kwargs – Additional keyword arguments to pass to contextily.plotting.add_basemap().

Returns:

Axis with the basemap plotted on it.

Return type:

matplotlib.axes.Axes

resplotlib.colormaps

resplotlib.colormaps.register_colormaps()[source]

Register custom colormaps.

resplotlib.explore

resplotlib.explore.explore_basemap(m: Map | Map, source: str = 'OpenStreetMap.Mapnik', **kwargs) Map | Map[source]

Add a basemap layer to an interactive map.

Parameters:
  • m (ipyleaflet.Map or Map) – Map to which to add the basemap layer.

  • source (str, optional) – Basemap source in the format “provider.layer_name”. Default is “OpenStreetMap.Mapnik”.

  • **kwargs – Additional keyword arguments to pass to ipyleaflet.basemap_to_tiles.

Returns:

Map with the basemap layer added.

Return type:

ipyleaflet.Map or Map

resplotlib.explore.explore_choropleth(gdf: GeoDataFrame, m: Map | Map, column: str, **kwargs) Map | Map[source]

Explore a geopandas.GeoDataFrame as a choropleth layer on a map.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to explore.

  • m (ipyleaflet.Map or Map) – Map on which to display the choropleth layer.

  • column (str) – Column to use for the choropleth values.

  • **kwargs – Additional keyword arguments to pass to ipyleaflet.Choropleth.

Returns:

Map with the GeoDataFrame added as a choropleth layer.

Return type:

ipyleaflet.Map or Map

resplotlib.explore.explore_da(da: DataArray, m: Map | Map | None = None, **kwargs) Map | Map[source]

Explore a xarray.DataArray in an interactive map.

Parameters:
  • da (xarray.DataArray) – DataArray to explore.

  • m (ipyleaflet.Map or Map, optional) – Map on which to display the DataArray. If None, a new map will be created. Default is None.

  • **kwargs – Additional keyword arguments to pass to odc.geo.xr.DataArrayAccessor.add_to.

Returns:

Map with the DataArray added as a layer.

Return type:

ipyleaflet.Map or Map

resplotlib.explore.explore_gdf(gdf: GeoDataFrame, m: Map | Map | None = None, column: str | None = None, **kwargs) Map | Map[source]

Explore a geopandas.GeoDataFrame in an interactive map.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to explore.

  • m (ipyleaflet.Map or Map, optional) – Map on which to display the GeoDataFrame. If None, a new map will be created. Default is None.

  • column (str, optional) – Column to use for choropleth values. If None, geometries will be plotted without a choropleth. Default is None.

  • **kwargs – Additional keyword arguments to pass to the underlying functions for plotting the GeoDataFrame.

Returns:

Map with the GeoDataFrame added as a layer.

Return type:

ipyleaflet.Map or Map

resplotlib.explore.explore_geojson(gdf: GeoDataFrame, m: Map | Map, **kwargs) Map | Map[source]

Explore a geopandas.GeoDataFrame as a GeoJSON layer on a map.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to explore.

  • m (ipyleaflet.Map or Map) – Map on which to display the GeoJSON layer.

  • **kwargs – Additional keyword arguments to pass to ipyleaflet.GeoJSON.

Returns:

Map with the GeoDataFrame added as a GeoJSON layer.

Return type:

ipyleaflet.Map or Map

resplotlib.explore.explore_uda(uda: UgridDataArray, m: Map | Map = None, **kwargs) Map | Map[source]

Explore a xugrid.UgridDataArray with an unstructured grid in an interactive map.

Parameters:
Returns:

Map with the DataArray added as a layer.

Return type:

ipyleaflet.Map or Map

resplotlib.geometries

resplotlib.geometries.plot_gdf(gdf: GeoDataFrame, ax: Axes, **kwargs) Axes[source]

Plot a geopandas.GeoDataFrame.

Parameters:
Returns:

Axis with the GeoDataFrame plotted on it

Return type:

matplotlib.axes.Axes

resplotlib.rescale

resplotlib.rescale.rescale_da(da: DataArray | Dataset, scale_factor: float) DataArray | Dataset[source]

Rescale the coordinates of a xarray.DataArray or xarray.Dataset by a specified scale factor.

Parameters:
  • da (xarray.DataArray | xarray.Dataset) – DataArray or Dataset to be rescaled.

  • scale_factor (float) – Factor by which to rescale the coordinates.

Returns:

Rescaled DataArray or Dataset.

Return type:

xarray.DataArray | xarray.Dataset

resplotlib.rescale.rescale_gdf(gdf: GeoDataFrame, scale_factor: float) GeoDataFrame[source]

Rescale the coordinates of a geopandas.GeoDataFrame by a specified scale factor.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame to be rescaled.

  • scale_factor (float) – Factor by which to rescale the geometries.

Returns:

Rescaled GeoDataFrame.

Return type:

geopandas.GeoDataFrame

resplotlib.rescale.rescale_uda(uda: UgridDataArray | UgridDataset, scale_factor: float) UgridDataArray[source]

Rescale the coordinates of a xugrid.UgridDataArray or xugrid.UgridDataset by a specified scale factor.

Parameters:
Returns:

Rescaled UgridDataArray or UgridDataset.

Return type:

xugrid.UgridDataArray | xugrid.UgridDataset

resplotlib.videos

resplotlib.videos.create_gif(file_path_images: list[str], file_path_gif: str, fps: int = 5, **kwargs) None[source]

Create a GIF from a list of images.

Parameters:
  • file_path_images (list[str]) – List of file paths to images.

  • file_path_gif (str) – File path for the output GIF.

  • fps (int, optional) – Frames per second for the GIF. Defaults to 5.

  • **kwargs – Additional keyword arguments to pass to imageio.mimsave().

resplotlib.videos.create_video(file_path_images: list[str], file_path_video: str, fps: int = 5, **kwargs) None[source]

Create a video from a list of images.

Parameters:
  • file_path_images (list[str]) – List of file paths to images.

  • file_path_video (str) – File path for the output video.

  • fps (int, optional) – Frames per second for the video. Defaults to 5.

  • **kwargs – Additional keyword arguments to pass to cv2.VideoWriter().

resplotlib.wrappers

resplotlib.wrappers.cbar_axis_wrapper(func: callable) callable[source]
resplotlib.wrappers.format_args_wrapper(func: callable) callable[source]
resplotlib.wrappers.format_axis_wrapper(func: callable) callable[source]
resplotlib.wrappers.guideline_wrapper(func: callable) callable[source]
resplotlib.wrappers.initialise_fig_wrapper(func: callable) callable[source]
resplotlib.wrappers.initialise_map_wrapper(func: callable) callable[source]
resplotlib.wrappers.overwrite_layer_wrapper(func: callable) callable[source]
resplotlib.wrappers.rescale_wrapper(func: callable) callable[source]
resplotlib.wrappers.show_kwargs_wrapper(func: callable) callable[source]
resplotlib.wrappers.skip_and_smooth_wrapper(func: callable) callable[source]

resplotlib.utils

resplotlib.utils.get_center_from_bounds(bounds: tuple[float, float, float, float]) tuple[float, float][source]

Get center from bounds.

Parameters:

bounds (tuple[float, float, float, float]) – Bounds (minx, miny, maxx, maxy).

Returns:

Center of the bounds (latitude, longitude).

Return type:

tuple[float, float]

resplotlib.utils.get_crs_from_data_or_crs(data_or_crs: DataArray | Dataset | UgridDataArray | UgridDataset | GeoDataFrame | CRS | CRS | str | None = None) CRS | None[source]

Get coordinate reference system (CRS) from data or CRS.

Parameters:

data_or_crs (xarray.DataArray | xarray.Dataset | xugrid.UgridDataArray | xugrid.UgridDataset | geopandas.GeoDataFrame | pyproj.CRS | rasterio.crs.CRS | str | None) – Data or coordinate reference system.

Returns:

Coordinate reference system.

Return type:

pyproj.CRS | None

resplotlib.utils.get_rescale_parameters(data_or_crs: DataArray | Dataset | UgridDataArray | UgridDataset | GeoDataFrame | CRS | CRS | str | None = None, rescale_unit: str | None = None) tuple[str | None, float][source]

Get rescale parameters from a coordinate reference system (CRS).

Parameters:
Returns:

Rescale unit and scale factor.

Return type:

tuple[str | None, float]

resplotlib.utils.get_xy_labels(data_or_crs: DataArray | Dataset | UgridDataArray | UgridDataset | GeoDataFrame | CRS | CRS | str | None = None, rescale_unit: str | None = None) tuple[str, str][source]

Get x and y axis labels from a coordinate reference system (CRS).

Parameters:
Returns:

x and y axis labels.

Return type:

tuple[str, str]

resplotlib.utils.get_zoom_from_bounds(bounds: tuple[float, float, float, float]) int[source]

Get approximate zoom level from bounds.

Parameters:

bounds (tuple[float, float, float, float]) – Bounds (minx, miny, maxx, maxy).

Returns:

Approximate zoom level of the bounds.

Return type:

int