Skip to content

[MNT]: MultiCursor should not take canvas as first parameter #21496

Closed

Description

@QuLogic

Summary

During the sprint, we were looking at widgets, and I noticed that the MultiCursor constructor takes a FigureCanvasBase as first parameter. This probably exists to say where to connect signals, but this does not match how any of the other widgets work, which infer this from the supplied Axes. Theoretically, I don't see any reason why the Axes need to be on a single Figure for MultiCursor to work, but that's implied by it only using a single canvas.

Proposed fix

The canvas should be found from the Axes, and the constructor should assert that all supplied Axes are on the same Figure (if that is indeed required.)

However, I don't know how to deprecate this. If we use _api.delete_parameter, then the remaining parameters become keyword-only, but we don't want to do that to the Axes parameter, which should have been the first positional parameter.

Activity

  1. anntzer commented on Oct 29, 2021

    @anntzer
    Contributor

    I guess you need to do it more or less by hand, taking *args, **kwargs as parameters and then emit a warning if "canvas" in kwargs or isinstance(args[0], FigureCanvasBase)? Then actually bind the args accordingly. (Something along these lines, untested.)

  2. added
    API: consistency
    on Nov 1, 2021
  3. anntzer commented on Nov 1, 2021

    @anntzer
    Contributor

    If we are going to mess up with the signature, perhaps we can also consider changing, at the same time, the somewhat unsightly horizOn/vertOn kwargs to both MultiCursor and Cursor? Currently some widgets use "orientation" and others use "direction", but I think standardizing on "orientation" is better ("direction" is also used for "in"/"out" for ticks, whereas colorbar uses "orientation" for horizontal/vertical).
    In the specific case of (Multi)Cursor, I'd suggest going for orientation="vertical"|"horizontal"|"both"?

  4. github-actions commented on Nov 7, 2025

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. added
    status: inactive
    on Nov 7, 2025
  6. timhoffm commented on Nov 7, 2025

    @timhoffm
    Member

    This now much easier due to the API narrowing in #23348

  7. added
    keep
    and removed
    status: inactive
    on Nov 7, 2025
  8. added 2 commits that reference this issue on Nov 9, 2025
    be55fdf
    1c6ccce
  9. added this to the v3.11.0 milestone on Dec 18, 2025
  10. removed
    keep
    on Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyMaintenance

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions