You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
I am not sure this is a bug per-say, but confusion over what coordinate system the incoming point is in. When it is first created, the artist has no transform which means it is implicitly the unit transfrom and all of your center, and radii are in the same coordinate frame. Once you add the patch to the axes we set the transform to be the data trasfrom (data space -> screen space) (see https://matplotlib.org/3.1.1/tutorials/advanced/transforms_tutorial.html). This means internal to contains_point we convert the path to screen units before asking if your point is in it but we do not transform the input point. In the screen coordinate frame (3, 5) is way down at the bottom corner of the figure. If you transfrom the input point to screen space via
it works again. I suspect the reason it behaves this way is that almost always when we are checking if a point falls in a path it is because we are seeing if a mouse event was over a given artist and there the "natural" input is screen units (as that is (more or less) what the GUI toolkits give us).
I tried to use
contains_point
method ofPatch
to check if some point is inside the closed path, e.g.I defined an ellipse with the center, width, height and angle parameters:
The last line prints out
True
, which means the center is in the defined ellipse. But after I added thee1
to an axes, the same line just print outFalse
, e.g.I'm testing the above with matplotlib of version 3.0.3. Is this a bug? Or something I did was not correct? Thanks!
The text was updated successfully, but these errors were encountered: