-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
imsave reduces 1row from the image #4280
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
The issue is on the write side. |
This looks like a float rounding issue. If you look at how In [16]: 100 * (481 / 100)
Out[16]: 480.99999999999994 This only happens at specific image sizes: tst = [j - 100 * (j / 100) for j in range(1000)]
fig, ax = plt.subplots()
ax.plot(tst)
ax.set_ylabel('$j - (100 * (j / 100))$')
ax.set_xlabel('$j$') The solution is to put a |
This only occurs with specific image dimensions (e.g. 481,321). It's seems fine at other sizes nearby:
Stepping through the execution of
Following all the way into
Replacing the output function to use PIL as a backend has no effect:
As
So the fault appears to be in |
I think I've found the culprit in
Returns:
The (Edit: changed the line/function above, I was working on my debug version through PIL) |
I bet you that that 481.0 is merely the display result of something that is On Thu, Mar 26, 2015 at 9:37 AM, Martin Fitzpatrick <
|
@WeatherGod definitely, was forgetting that those really really small values showed nothing. Modifying
Not sure if there are any potential negative side effects here though. |
Got trapped by the same bug. For anybody looking for a quick solution, a way around this is to set
Note that PNGs of dpi=1 will not play well with pdflatex. That's why the dpi setting was introduced in the first place, but possibly not carefully enough. A way around that is to either set the dpi to the greatest common divisor of height and width, or, if that is still too small, strip the dpi from the resulting PNG afterwards. |
Round images sizes to the nearest integer rather than clipping when passing down to the c++ layer. This is mostly a problem when using imsave/figimage to render an image 1:1 and is a result of float precision issues when computing number of pixels from inches/dpi. Closes matplotlib#4280
Punting as this requires changes in the Agg layer and will not get done before the 1.5 release. |
Steps to reproduce :
It removes one row !
The text was updated successfully, but these errors were encountered: