Q:

Plot matrix as heatmap with given cell size in python

I tried to google, but couldn't find any answer. 
I have a numpy ndarray with values I want to plot as a plain (no axes and stuff) heatmap where every rectangle is colored by given value. 
I want to have it so that the height of one cell is 1px and the width is 5px.
The final result is a png.
Is there a way in python to plot this with those cell size parameters?
I tried PIL with given total width and height, but the image doesn't look clear. 
All the best,
L.

A:

EDIT: Okay, here is another approach using the scipy.misc.imsave() function
import numpy as np
import matplotlib.cm as cm
import scipy.misc

# generate random data
data = np.random.rand(20,20)
# map the data to a color
colormap = cm.ScalarMappable(cmap="autumn")
im  = colormap.to_rgba(data)
# scale the data to a width of 5 pixels
im = np.repeat(im, 5, axis=1)
# save the picture
scipy.misc.imsave('test.png', im)

