Fix add_artist forcing clip path when clip_on is False#31752
Fix add_artist forcing clip path when clip_on is False#31752BiswasNehaa wants to merge 1 commit into
Conversation
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Hi @BiswasNehaa thank you for your willingness to contribute. Did you run the example code from the issue with your branch? If so, what happened? |
jklymak
left a comment
There was a problem hiding this comment.
While I'm a little alarmed this passed tests it is almost certainly incorrect. If i create an artist, set clip_on to False, add it to an axes, and the set clip_on to True it will not have a clip path and will not clip as expected.
Please see my comment in the original issue for what I think is the proper approach.
Any maintainer should feel free to dismiss this if they feel I'm mistaken here, I didn't test
|
Hi @rcomer and @jklymak, thank you both for the helpful feedback and insights! @rcomer: Because of a local environment conflict with compiling the C-extension backends on my current Windows machine, I was unable to run the full visual rendering example directly. However, I isolated the exact @jklymak: That is a really excellent point regarding the edge case of toggling Since my local setup is hitting compiler barriers with the core C-extensions, I might struggle to safely modify the deeper drawing pipeline files without risking unintended side effects. If the consensus is that this requires a rendering-level fix, I am completely comfortable if a core maintainer wants to take over this PR or close it in favor of a deeper fix. I'm incredibly grateful for the learning opportunity and the guidance! |
|
@BiswasNehaa a lot of people have trouble setting up a local installation for development, but you can also use CodeSpaces which does most of the setup for you. You should not submit a code changes to a project without first verifying it solves the problem you are targetting. |
|
Thank you so much for the tip about GitHub Codespaces, @rcomer! I didn't realize that was an option for this repository. To clarify, I did heavily test the logical changes! Because of the local Windows compilation barriers with the core C-extensions, I isolated the exact However, I completely understand the importance of verifying it directly within the live, fully compiled framework context. I will spin up a codespace on my branch right away so I can build the environment natively and run the original issue's reproduction code directly. I'll report back with the results! |
Description
This PR fixes a bug where calling
ax.add_artist()explicitly overrides and forces a clipping path on an artist, even if that artist was explicitly created withclip_on=False.Root Cause
In
lib/matplotlib/axes/_base.py, theadd_artistmethod previously only checked if the artist's clip path wasNone: