-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Missing axes limits auto-scaling support for LineCollection #29219
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
|
Hello, would this be a good first issue? This is my first time contributing to Matplotlib, can I take a look at this? I know issues will not be assigned and PRs are considered on a first come first serve basis, but I need to work on an issue for a school project so I am wondering how much learning curve this requires. |
There is already a PR open to fix this, linked above. I have not looked at it myself to see what state it is in. |
Looking through the Edit: autoscaling is discussed explicitly in this example. |
@rcomer "Intentional" or not, the current behavior is not user-friendly and should be improved. |
@carlosgmartin I agree that the current behaviour is unlikely to be what anyone wants. Indeed, if you plot something else that has autoscaling after adding the collection then it autoscales both. Whether something gets autoscaled should not depend on whether you add something after. from matplotlib import pyplot as plt
from matplotlib.collections import LineCollection
lc = LineCollection([[(x, x ** 2) for x in range(5)]])
ax = plt.gca()
ax.add_collection(lc)
ax.plot([1, 0])
plt.show() However, it does appear to have been deliberately written this way and I think we should try to understand why it was written this way. Understanding that can help us scope what kind of task it would be to change it. |
If we simply add a call to
|
We have a lazy limit update mechanism, but I donβt know the details and which part of the code are responsible for which aspects of that. I believe we have to clarify this to find out, what the right solution is. It might also be that this is currently not handled consistently across functions. |
The purpose of the test was to get coverage, so the test image is just randomly generated. My impression is though that everything is shown in the test image so the compression is not caused by things that are not drawn. I guess seeing the axis here would be interesting to understand what happens. (As the data is randomly generated, I guess I just tried things until I got a reasonable looking image.) Note that this test was for a previously untested part of the ps-backend, so it may very well be that there is a bug in the ps-backend and that one should run the same code with other backends so see if that is the case... |
Running the code in the qt-backend gives a differently looking image. The scatter looks quite similar, but the Saving it as PDF leads to a similar image as the test image, but no black edges. (both are screen shots) So something is quite strange here... Edit: this is on 3.8.3 |
I think the black edges are just because the test runs in "classic" mode. |
Could be. Documentation may lead one to believe differently:
The return value of |
I read up a bit in the source and there is I can sort out a correction to the documentation if nothing else. |
Bug summary
Matplotlib is missing auto-scale support for LineCollection.
Related issues:
add_collection3d
does not update view limitsΒ #23317Code for reproduction
Actual outcome
Expected outcome
Additional information
No response
Operating system
macOS 14.6.1
Matplotlib Version
3.9.3
Matplotlib Backend
macosx
Python version
3.12.7
Jupyter version
7.2.2
Installation
pip
The text was updated successfully, but these errors were encountered: