Skip to content
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

imshow rendering issue #5959

Closed
mcspritz opened this issue Feb 2, 2016 · 11 comments
Closed

imshow rendering issue #5959

mcspritz opened this issue Feb 2, 2016 · 11 comments
Assignees
Milestone

Comments

@mcspritz
Copy link

mcspritz commented Feb 2, 2016

Hi, I'm plotting this simple graph and I got non equal pixel sizes for the graph, it happens with all kind of sizes and dpi.
(I'm using matplotlib 1.5.0, python 3.5.1)
I can prove with some pictures as well if needed (I'm not sure if the bug is in matplotlib or in the renderer).

from matplotlib import use
use('Agg')
import matplotlib.pyplot as plt
import numpy as np

t = np.random.randn(64, 64)
fig, ax = plt.subplots()
ax.imshow(t, interpolation='none', origin="lower")
plt.savefig(
    'crap29.png',
    format='png'
)
plt.close()`

Thanks

@jenshnielsen
Copy link
Member

Im not completely sure I understand what you issue is. Your code is plotting an image and not a graph? Please attach the image that you save not as a prof but to demonstrate what you are talking about.

@mcspritz
Copy link
Author

mcspritz commented Feb 2, 2016

Sorry, I knew it wasn't easy to explain.
I traced a line on the graphs and noticed that "pixes" of the imshow are not all of the same size.

crap29
crap29-zoomed

@jenshnielsen
Copy link
Member

The issue sounds somewhat related to #5520 which is fixed by the rather large image rewrite in #5718 but I am not sure

@tacaswell
Copy link
Member

Does it work correctly with 'nearest'?

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Feb 2, 2016
@mcspritz
Copy link
Author

mcspritz commented Feb 2, 2016

Nope, I also tried to raise the dpi but no luck.
nearest-zoomed

@jenshnielsen
Copy link
Member

We have merge large changes to the image algorithm in to master and 2.x @mcspritz if possible could you try testing this on the 2.x branch or master?

@mcspritz
Copy link
Author

Hi, I'm a newbie and want to know a simple thing, I built the cloned v2.x branch and it shows version 1.5.1+282.g918e80e, is this correct or I'm doing something wrong?

Thanks.

@jenshnielsen
Copy link
Member

Yes that means that its 1.5.1 + 282 new commits on top of that which is the current state of the 2.x branch

@mcspritz
Copy link
Author

Thanks,

So, the image is much better, I found for low number of pixels that column 0 has a pixel less.
matplotlib-16x16

For bigger images things get more complicated.
matplotlib-320x256

@mdboom
Copy link
Member

mdboom commented Mar 14, 2016

I think what we're seeing here is the case where the scaling factor from data points to on-screen pixels is not an integer multiple. Imagine a 64x64 array scaled up to 200x200pixels. Since 64 does not divide into 200 evenly, it's inevitable that not all data points will be rendered at the same size. If I were seeing data points that were more than one pixel different in size, I'd be worried, but in the first example I'm seeing data points of 6 or 7 pixels, and in the last example 1 or 2 pixels. So I'm not sure we could logically do any better (other than adding a mode and the inevitable complexity that would always ensure an integral scaling factor).

@mdboom
Copy link
Member

mdboom commented Apr 11, 2016

Closing this, as I don't think there's a bug here, but feel free to continue to comment.

@mdboom mdboom closed this as completed Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants