Take the 2-minute tour ×

I'm trying to plot a matrix assign to each element a color based on its value. I used pcolor() from Matplotlib.pyplot library (coding in Python):


I tested with a 5000 x 5000 matrix but I had serious memory leak problems. As I found on some forums I updated to the newest version of matplotlib but I still have the problem. I ran it on a cluster setting 80GB of memory but these are not enough!! Suggestions on how can I resolve this memory leak?

share|improve this question
What do you mean 'memory leak'? Using more memory than you expect does not mean it has a leak, just that it uses more than you expect. –  tcaswell Apr 23 '13 at 4:38
But I think that using more than 80GB to plot a 5000x5000 matrix is not something normal! –  Lazza87 Apr 23 '13 at 8:48
pcolor draws a separate polygon for every cell, and therefore has rather excessive memory usage. It's not intended for large regular grids (it supports triangular cells, etc). Use pcolormesh instead if you want vector output or imshow if you want a colored image. pcolormesh is intended for large regular grids, but still produces vector output like pcolor. imshow is much more efficient than either, but will produce a image, rather than vector output. –  Joe Kington Apr 23 '13 at 13:11
@JoeKington - I'd suggest that was a good answer to the question... –  pelson Aug 16 '13 at 7:45
add comment


Your Answer



Browse other questions tagged or ask your own question.