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

'nearest' interpolation not working with low dpi #5520

Closed
christine-e-smit opened this issue Nov 19, 2015 · 2 comments
Closed

'nearest' interpolation not working with low dpi #5520

christine-e-smit opened this issue Nov 19, 2015 · 2 comments
Milestone

Comments

@christine-e-smit
Copy link

christine-e-smit commented Nov 19, 2015

I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 (64-bit).

In this script, I am creating a 7x7 pixel image from a 7x7 data matrics. I expect to see one pixel per data point, but that's not what I'm seeing. The data is an identity matrix, so I should see a one pixel diagonal line. Instead, I'm seeing an odd 2x2 pixel blob in the middle of the diagonal.

#! /bin/env python

import numpy as np
import matplotlib.pylab as plt

if __name__ == "__main__":
    '''
    Simple script to create 7x7-pixel image with a diagnonal line.
    '''
    n = 7
    data = np.identity(n, float)

    # Create an nxn size figure with no frame
    fig = plt.figure(figsize=(n, n), frameon=False)

    # make the axes to the edge of the figure
    ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
    # turn the axes off
    ax.set_axis_off()
    # add the axes to this figure
    fig.add_axes(ax)
    # show the data. Don't do any interpolation.
    ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto')
    # Save the figure at 1 dot per inch, which should mean 1 data point per
    # pixel
    fig.savefig("image.png", dpi=1)

Here is the image, which is obviously teeny tiny. You can see the issue if you open it in something like gimp, which lets you zoom in: image

@rougier
Copy link
Member

rougier commented Nov 19, 2015

Just adding a zoom of the image above.

image

@tacaswell
Copy link
Member

possibly related to #4406 / #4280

mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 5, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 5, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 5, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 8, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 25, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 27, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Jan 28, 2016
mdboom added a commit to mdboom/matplotlib that referenced this issue Feb 9, 2016
@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Feb 18, 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