title: How to make Matplotlib redraw faster?
body: <p>I have to plot a grid of subplots (16x16 ones, for example). I use <code>matplotlib</code> but It is a bit too slow, especially when I have to redraw the plots (for example, when their size is changed). How can I make it faster?</p>
  
  <p>P.S. Here is an example of code:</p>
  
  <pre><code>import sys
  import matplotlib
  matplotlib.use('Qt4Agg')
  import pylab
  
  from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.figure import Figure
  
  import PyQt4
  from PyQt4 import QtCore, QtGui, Qt
  
  if __name__ == '__main__':
      app = QtGui.QApplication(sys.argv)
  
      # generate the plot
      fig = Figure(figsize=(800, 800), facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
  
      for i in range(256):
          ax = fig.add_subplot(16, 16, i)
          ax.plot([0, 1])
          ax.set_xticks([])
          ax.set_yticks([])
  #        ax.set_title("Mega %i" % (i,))
  
      # generate the canvas to display the plot
      canvas = FigureCanvas(fig)
      canvas.setMinimumWidth(640)
      canvas.setMinimumHeight(640)
  
      # generate layout
      layout = QtGui.QVBoxLayout();
      layout.addWidget(canvas)
      layout.setGeometry(QtCore.QRect(0, 0, 1000, 1000))
  
      # generate widget
      widget = QtGui.QWidget()
      widget.setLayout(layout)
  
      # generate scroll area
      win = QtGui.QScrollArea()
      win.setWidget(widget)
      win.setMinimumWidth(100)
      win.setWidgetResizable(True)
      win.show()
  
      canvas.draw()
  
      sys.exit(app.exec_())
  </code></pre>