pypsa.plot.add_legend_circles

pypsa.plot.add_legend_circles#

pypsa.plot.add_legend_circles(ax: Axes, sizes: list[float] | ndarray, labels: list[str] | ndarray, srid: int = 4326, patch_kw: dict[str, Any] | None = None, legend_kw: dict[str, Any] | None = None) Legend#

Add a legend for reference circles.

Warning

When combining n.plot() with other plots on a geographical axis, ensure n.plot() is called first or the final axis extent is set initially (ax.set_extent(boundaries, crs=crs)) for consistent legend circle sizes.

Parameters:
  • ax (matplotlib ax) – Matplotlib axis to add the legend to.

  • sizes (list-like, float) – Size of the reference circle; for example [3, 2, 1]

  • labels (list-like, str) – Label of the reference circle; for example [“30 GW”, “20 GW”, “10 GW”]

  • srid (int, defaults to DEFAULT_EPSG) – Spatial reference ID for area correction

  • patch_kw (defaults to {}) – Keyword arguments passed to matplotlib.patches.Circle

  • legend_kw (defaults to {}) – Keyword arguments passed to ax.legend