Skip to content

[ENH]: ContourSet.set_paths #26340

Closed

Description

@rcomer

Problem

To get contour labelling working with its special transforms, Cartopy has a workaround where it replaces all the paths on the ContourSet with transformed versions. This currently looks like

paths = cs.get_paths()
paths[:] = transformed_paths

which doesn’t smell very good.

Proposed solution

The above would smell better as

cs.set_paths(transformed_paths)

Activity

  1. anntzer commented on Jul 18, 2023

    @anntzer
    Contributor

    I'm actually a bit confused as to why Collection.set_paths raises NotImplementedError instead of setting self._paths (which is what Collection.get_paths already returns).

  2. rcomer commented on Jul 18, 2023

    @rcomer
    MemberAuthor

    Thanks @anntzer. So would it be enough to just copy what PathCollection has?

    def set_paths(self, paths):
    self._paths = paths
    self.stale = True

  3. anntzer commented on Jul 18, 2023

    @anntzer
    Contributor

    Untested, but possibly yes?

  4. added this to the v3.8.0 milestone on Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions