I have a 2D array of values in crud dimensions (65000x256). I need to plot this data to an image that has exactly one pixel for each value.
def save_image_data(data, cm, fn):
#Source https://fengl.org /2014/07/09/matplotlib-savefig-without-borderframe/
sizes = np.shape(data)
height = float(sizes[0])
width = float(sizes[1])
fig = plt.figure()
fig.set_size_inches(width/height, 1, forward=False)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax.imshow(data, cmap=cm)
plt.pause(1)
plt.savefig(fn, dpi = height, transparent=False)
plt.close()
There are no error messages. However the resulting images are in very very very low DPI since there are white borders on top and bottom of the image.