-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: transform keyword in ax.plot(...) #21008
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
I agree this seems like a bug. It is very strange in that |
This is due to matplotlib/lib/matplotlib/lines.py Line 663 in 8ce14fb
causing a slicing of the data if the size is greater than 1000 (hard coded!) and then the slicing only happening in the view window, which has been transformed. i.e. your data goes from 0 to 4pi, but the window goes from 20 to 20 + 4pi. So all the data is sliced away, and nothing is plotted. I'm not sure what the todo is here. My tendency would be to just remove the slicing under the hope that modern machines don't need this optimization. As you can see it is only applied in a very limited set of circumstances. Conversely, one could (should) apply the transform to the data first, but that is a bit ugly. This optimization was last touched 12 years ago. |
I am transforming the data manually now. However, my idea when using
transforms would be in not duplicating the data, of course.
…On Tue, Sep 7, 2021 at 11:51 AM Jody Klymak ***@***.***> wrote:
This is due to
https://github.com/matplotlib/matplotlib/blob/8ce14fb60d9441ce3fb92e6e59b4aa3146aca6c1/lib/matplotlib/lines.py#L663
causing a slicing of the data if the size is greater than 1000 (hard
coded!) and then the slicing only happening in the view window, which has
been transformed. i.e. your *data* goes from 0 to 4*pi, but the window
goes from 20 to 20 + 4*pi. So all the data is sliced away, and nothing is
plotted.
I'm not sure what the todo is here. My tendency would be to just remove
the slicing under the hope that modern machines don't need this
optimization. As you can see it is only applied in a very limited set of
circumstances. Conversely, one could (should) apply the transform to the
data first, but that is a bit ugly.
This optimization was last touched 12 years ago.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#21008 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAKSHH6U2P2XP7XKCJIXFDUAXOBRANCNFSM5DR5G3QQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I would just add a check to restrict the optimization to the case where |
Yeah that's reasonable as well. OTOH it's a pretty specialized optimization. |
Gosh, this is deep. The condition to allow for the optimization turned out not sufficiently excluding after all. When I found this bug, the outcome of the plotting was not obviously wrong. Namely, I used the transform to account for the units. When up-scaling (smaller units), the plot appeared as expected, but when down-scaling, the plot was visible, but smaller that the original and cut. This made me think that I am not getting some matplotlib argument right. However, when the 1000 threshold appeared, things become more certain. |
We should totally fix this, but the question is if we a) remove the optimization or if we b) add yet another exclusion to it? I guess I prefer a), though that is a breaking change. |
I guess we need a benchmark to have the full picture. |
Bug summary
The keyword argument
transform
of the method ax.plot(...) malfunctions with size of the samples greater than 1000.For example, the following script
Produces an expected figure
with
num=1000
and an empty figure
with
num=1001
.Code for reproduction
Actual outcome
Expected outcome
Operating system
Linux
Matplotlib Version
3.4.3
Matplotlib Backend
Qt5Agg
Python version
Python 3.8.7
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response
The text was updated successfully, but these errors were encountered: