-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Milestone
Description
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:
Metadata
Metadata
Assignees
Labels
No labels