Skip to content

Conversation

pelson
Copy link
Member

@pelson pelson commented Jan 7, 2019

Rationale

After debugging the issue with matplotlib's contour labelling (seen in #13), it is clear that it was designed before there was a strong transform and path capability. For example, it assumes that there is only one polygon per Path (it completely ignores codes), and it also assumes that paths can be transformed by simply transforming the vertices. Because of this I solved the problem by pre-transforming the paths to the axes coordinate system, and splitting any multi-poly Paths. With this in place, the existing contour labelling functionality works reasonably well (there is room for improvement with the label placement, but that would be a matplotlib enhancement).

figure_1

Implications

  • Closes Contour labelling #13 (thirteen! - that was a long time ago)
  • Works around an issue in matplotlib. It is feasible to address this directly in matplotlib (by re-writing some of the algorithm, and splitting other parts out into the matplotlib.path module. I haven't done this yet, and don't think I will have the time to do it justice
  • Changes the type that comes out of GeoAxes.contour[f] to a cartopy.mpl.contour.GeoContourSet (via ugly polymorphism)
  • Users can use matplotlib's click-to-label functionality, which is nearly cool 😄(I get an ugly traceback on exit).

manual_labels

@pelson pelson force-pushed the contour_labels branch 2 times, most recently from 40e271f to 37c0228 Compare January 10, 2019 13:30
Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resetting __class__ is a bit gnarly, but I don't see a better way without a bunch more boilerplate code.

@pelson
Copy link
Member Author

pelson commented Jan 30, 2019

@dopplershift - merge at will!

@dopplershift dopplershift merged commit 04a135c into SciTools:master Jan 30, 2019
@QuLogic QuLogic added this to the 0.18 milestone Jan 30, 2019
@pelson pelson deleted the contour_labels branch January 30, 2019 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants