-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
memory error using savefig with ylim to create pdf of box plots #10889
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
Can you please provide a minimal runnable example. See http://sscce.org. |
like this? try to change datatype to svg or png. without ylim there are no problems, too. it looks like that this problem only shows with very large negative numbers.
|
I can reproduce the memory error with python 2.7, matplotlib 2.2.2, TkAgg as well as Qt4Agg. I can also reproduce with python 3.6, master, Qt5Agg. Both on Windows8.1. What's funny is that it works fine for the last data value being set to |
I cannot reproduce this with Python 3.6, MPL v2.2.2 on (Windows subsystem for) Linux |
I also cannot reproduce this on vanilla Windows with Python 3.6 and MPL v2.1.2 & v2.2.2 on my admittedly pretty high-end work machine. I can report however that the test case with the zoomed limits does seem to take much longer to render than it should. |
I General we don’t garauntee to filter every bad value out of the input. In this case I can only assume the very large numbers are meant to represent bad data. Suggest masking your arrays before passing to boxplot or any other Matplotlib function is the right way to specify data as bad otherwise you are bound to hit floating point problems somewhere along the line. |
@jklymak |
one thing to check: inspect the artists that represent the whiskers and see how many points are in that path |
@ImportanceOfBeingErnest Yes, Do this: a = np.array([1e10], dtype=np.float64)
b = np.array([5.], dtype=np.float64)
c = a-b
d = c-a
print(d) you get Now do a = np.array([1e17], dtype=np.float64)
b = np.array([5.], dtype=np.float64)
c = a-b
d = c-a
print(d)
So yes, I don't know thats the problem here, but I do know that mixing |
I don't quite get the point. Surely any maths on those numbers is accurate within the limits of floating point accuracy. Compared to 1e34 it does not actually matter if some result is +5 or -5. But this issue is not about the wrong mean shown on the plot or similar. |
Because the error is only triggered when zooming in to -5 to +5... |
Ok, agreed, I mean it's just a memory error from a plot with 2 boxes and 10 lines. Can't be that serious after all. |
This is super weird. The exception is coming from Lines 1184 to 1232 in a9a495e
percision looks like it is 6 (hard-coded).
|
btw i have got that error after i changed the order of the boxes. maybe the error is dependent on the positon of the very large negative number (while zoomed in). |
I did not dig deep enough, Lines 1047 to 1182 in a9a495e
MemoryError by matplotlib/src/_path_wrapper.cpp Lines 739 to 747 in a9a495e
|
The problem is that |
The int version of the buffer size was not updated when the buffer was resized. It's there to prevent a signed/unsigned comparison warning, but it's simpler just to cast the other side of the comparison. There's no problem with the signed-to-unsigned cast since we already know that the result is positive due to the previous check. Fixes matplotlib#10889.
The int version of the buffer size was not updated when the buffer was resized. It's there to prevent a signed/unsigned comparison warning, but it's simpler just to cast the other side of the comparison. There's no problem with the signed-to-unsigned cast since we already know that the result is positive due to the previous check. Fixes matplotlib#10889.
Bug report
Bug summary
This is my first post. I am working with python for 3 weeks and i am completly new to this topic
savefig while using ylim for box plots gives sometimes a memory error. saveing as png or svg, or not using ylim workes fine.
my guess: despite of limiting the plot with ylim savefig just "zoom" in which can create very long distances even they are not part of the plot anymore which just hit some pdf limitations. in this case there is a data point at 1e39. when i use ylim(-2,2) there is a huge distence which is not part of the plot maybe this causes the memory error.
ram was fine the whole time.
i hope this helps.
code in comments
Actual outcome
Expected outcome
pdf files for all plots
Matplotlib version
print(matplotlib.get_backend())
): TkAggi am at work i think it was installed via pip
The text was updated successfully, but these errors were encountered: