[Matplotlib-users] plotting large images

2013-08-27 Thread Štěpán Turek
Hi, I would like to plot multiple overlayed 4096x4096 images in one axes. If I run this code the plot takes 300 MB of memory: import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__':     img = np.zeros((4096, 4096))     img[100: 300, 100:1500] = 200    

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Oliver
You could, before plotting, sum the different image arrays? Depending on whether you are plotting RGB(A) images or greyscale images, you could take the sum of the color channels, or take a weighted average. The method you use here depends strongly on the image type, but it will reduce memory

Re: [Matplotlib-users] Graph ticks label missing !

2013-08-27 Thread Nicolas Mailhot
Le Lun 26 août 2013 18:21, Goyo a écrit : 2013/7/19 Nicolas Mailhot nicolas.mail...@laposte.net: Le Mer 17 juillet 2013 14:56, Michael Droettboom a écrit : Can you please provide a completely standalone example? The following code has undefined variables etc. Here it is, I'm afraid this

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Štěpán Turek
Hi, You could, before plotting, sum the different image arrays? Depending on whether you are plotting RGB(A) images or greyscale images, you could take the sum of the color channels, or take a weighted average. Yes, I will probably merge the images (RGBA) before plotting. I want to

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Oliver
Those numbers actually make a lot of sense. For a 4k by 4k 2D array of 64-bit floats, you're using 128MiB of memory, just to store them. Displaying such an array with mpl would take a copy of that and add some objects for housekeeping (on my machine about 150MB to display one such array together

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Štěpán Turek
You could look at whether or not you actually need 64-bit precision. Often times, 8-bit precision per color channel is justifiable, even in grayscale. My advice is to play with the dtype of your array or, as you mentioned, resample. thanks, this helped me significantly,  uint8 

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Chris Beaumont
I've been burned by this before as well. MPL stores some intermediate data products (for example, scaled RGB copies) at full resolution, even though the final rendered image is downsampled depending on screen resolution. I've used some hacky tricks to get around this, which mostly involve

Re: [Matplotlib-users] plotting large images

2013-08-27 Thread Michael Droettboom
On 08/27/2013 09:49 AM, Chris Beaumont wrote: I've been burned by this before as well. MPL stores some intermediate data products (for example, scaled RGB copies) at full resolution, even though the final rendered image is downsampled depending on screen resolution. I've used some hacky