Skip to content

aliasing with imshow(z, interpolation = 'none'), when saved as a pdf #2972

Closed
@breedlun

Description

@breedlun

I am finding that matplotlib v1.3.0 will blur the edges of an image's pixels when I use interpolation = 'none' and save the image as a pdf. For example, the following code

z = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]])
fig1 = plt.figure()
ax = plt.subplot()
ax.imshow(z, interpolation = 'none')
plt.savefig('none.png')

produces the following png,

none

which looks just like the matplotlib figure window, as it should. However, when I save the figure as a pdf

plt.savefig('none.pdf')

I get the following pdf,

none pdf

Perhaps this is the intended mode of operation, but IMHO the output file should look like the figure window. Fortunately, there is a work around. If use interpolation = 'nearest', everything is hunky dory:

fig2 = plt.figure()
ax = plt.subplot()
ax.imshow(z, interpolation = 'nearest')
plt.savefig('nearest.pdf')

nearest pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions