Skip to content

Check if point is in path or not by contains_point #14207

@zhangt58

Description

@zhangt58

I tried to use contains_point method of Patch to check if some point is inside the closed path, e.g.
I defined an ellipse with the center, width, height and angle parameters:

>>> from matplotlib.patches import Ellipse
>>> e1 = Ellipse((3,5), 10, 8, 20)
>>> e1.contains_point((3,5))
True

The last line prints out True, which means the center is in the defined ellipse. But after I added the e1 to an axes, the same line just print out False, e.g.

>>> import matplotlib.pyplot as plt
>>> from matplotlib.patches import Ellipse
>>> fig, ax = plt.subplots()
>>> e1 = Ellipse((3,5), 10, 8, 20)
>>> e1.contains_point((3,5))
True
>>> ax.add_patch(e1)
>>> e1.contains_point((3,5))
False

I'm testing the above with matplotlib of version 3.0.3. Is this a bug? Or something I did was not correct? Thanks!

Metadata

Metadata

Assignees

No one assigned

    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