-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: (Tight) layout engine breaks for 3D patches #27361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report @thrien. I confirm that I have reproduced this with The problem is that the A workaround is to call |
Quick reply, but I think I have fixed a similar bug earlier. Hence, it may be good to check all 3D-objects for similar problems. |
What happens if the attribute exists but the view angle changed since it was created? I wonder if we need to just always re-create. That seems to be what happens within |
Good question. It can probably be wrong (but not crash...). Maybe one need some sort of " I guess one way can be to add an optional argument to all the get-methods which controls if the 3D-projection should be done before getting the result. True by default, but can be set to False if performance becomes a problem and one know that it is not required. |
That's seems like an easy fix. However I cannot build myself because of some annoying issues with the setup. (I'm trying this for the first time). So I can't do it myself (yet). |
I fixed my issues and was able to build a version with the simple fix following the suggestion of @oscargus. It does not address the "stale" issue mentioned above. The commit is here. I was able to build and then run the new test that I've implemented. However I was not able to run all the tests. Should I already create a pull request? It is only a partial solution but it is still an improvement since as far as I understand at draw the projection will always be called again so everything that worked before should still work the same. (Maybe someone can comment on whether the docstring is actually inherited because I have no idea how this works.) |
I think that patch is good to open a PR with. Yes, the doc-string should be inherited. |
Uh oh!
There was an error while loading. Please reload this page.
Bug summary
The tight layout sometimes breaks for plots with 3D patches because 'PathPatch3D' object has no attribute '_path2d'.
Code for reproduction
Actual outcome
Expected outcome
The following code actually produces (something that is at least close enough to) the expected outcome. It does NOT produce an error even though I would expect it to be equivalent.
The result is different compared to the case without the tight layout engine, so I assume it is doing something. However I am not sure if it is fully doing it's job.
Additional information
Whether I get an error or not depends on some weird circumstances (e.g. the behaviour depends on dpi settings). I left some possible modifications as comments in the minimal example above. Here is a short summary of some test I did:
layout="tight"
works withfig.savefig("test.png")
but NOT withfig.savefig("test.png", dpi=300)
.plt.subplots(..., dpi=300)
orfig.set_dpi(300)
the call tofig.tight_layout()
already gives an error and NOT the call tofig.savefig()
.layout="tight"
it also breaks for"compressed"
or"constrained"
.Operating system
Arch
Matplotlib Version
3.7.1
Matplotlib Backend
QtAgg
Python version
Python 3.11.5
Jupyter version
No response
Installation
Linux package manager
The text was updated successfully, but these errors were encountered: