Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for labelling contours #218

Open
raphaelquast opened this issue Dec 21, 2023 · 0 comments
Open

Add support for labelling contours #218

raphaelquast opened this issue Dec 21, 2023 · 0 comments

Comments

@raphaelquast
Copy link
Owner

raphaelquast commented Dec 21, 2023

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

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

No branches or pull requests

1 participant