Skip to content

Add support for labelling contours #218

Description

@raphaelquast

Using m.ax.clabel() to label contour-lines in a plot is currently not working.

After using clabel, the following problems occur

  • resulting contours are no longer on the dedicated layer (they are re-drawn and appear on the default ("base") layer
  • the initial contours remain in the blit-manager as "artists without a figure"
from eomaps import Maps
import numpy as np
Maps.config(log_level="debug")

x, y = np.meshgrid(np.linspace(-40, 40, 50), np.linspace(-25, 30, 50))
data = x**2 + y**2
data = dict(
            data=pd.DataFrame(
                dict(lon=x.ravel(), lat=y.ravel(), value=data.ravel())
            ).sample(500),
            x="lon",
            y="lat",
            parameter="value",
        )

m = Maps(ax=221, figsize=(10, 6))
m.add_feature.preset.coastline()

m2 = m.new_layer("contour")
m2 .set_data(**data)
m2.set_shape.contour(filled=False)
m2.plot_map()

arts = m2.ax.clabel(m2.coll.contour_set)
for a in arts:
    m2.BM.add_bg_artist(a, layer=m2.layer)

m.show_layer(m.layer, m2.layer)

Describe the solution you'd like
Would be nice to get this working... or to explicitly provide a method to properly label contour-plots.

Issue was reported in the PyOpenSci Review

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions