Skip to content

Request an inaxes method in Figure to calculate whether a point is in an axes. #9821

@lkjell

Description

@lkjell

Request an inaxes method in Figure to calculate whether a point is in an axes and return the axes. i.e.

def inaxes(self, xy):
    axes_list = [a for a in self.get_axes() if a.patch.contains_point(xy)]

    if len(axes_list) == 0:
        axes = None
    elif len(axes_list) > 1:  # Overlap, get the highest zorder
        axes_list.sort(key=lambda x: x.zorder)
        axes = axes_list[-1]  # Use the highest zorder
    else:
        axes = axes_list[0]

    return axes

Rational: This make it easier (in my opinion) to find a method that do the requested method. Alternative is to create a LocationEvent and use the inaxes attribute. Using the LocationEvent class may trigger axes_enter_event and axes_leave_event.

In any cases a good documentation on matplotlib's coordinate and how to convert different backends' coordinate to matplotlib, most of the time flip the y axis, is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy