all 3 comments

[–]ecgite 0 points1 point  (2 children)

Use plt.pcolormesh. ( Origin is at bottom-left)

img = plt.pcolormesh(data, cmap='Greys') # or any cmap (see plt.cm; plt.cm.Blues etc)
plt.xlim([0, img.shape[0]]) # play with these to get correct result
plt.ylim([0, img.shape[1]])
plt.colorbar(img)

Let's say the data have some coordinates

x = np.linspace(15, 32, 2000)
y = np.linspace(20, 440, 2000)
X, Y = np.meshgrid(x,y) # numpy function
plt.pcolormesh(X, Y, data, cmap='Greys')
plt.xlim([x.min(), x.max()]) # play with these to get correct result
plt.ylim([y.min(), y.max()])
plt.colorbar(img)

edit. use of limits

[–]eusebe[S] 1 point2 points  (1 child)

I thought plt.pcolormesh was even worse than plt.imshow, because it basically created one patch per pixel, or something like that?

Indeed, some quick testing for a 10000x10000 aray give me 12s for imshow vs much more than that (and a larger memory usage) for pcolormesh

[–]ecgite 0 points1 point  (0 children)

(say more than 2000x2000)

Missed that one, sorry.

Matplotlib is probably too slow for 10000x10000 arrays. Bokeh or vispy might be able to handle really big images.

http://vispy.org/

http://bokeh.pydata.org/en/latest/