title: How to draw a frame on a matplotlib figure
body: <p>I want to show the frame in this figure.
  <a href="https://i.stack.imgur.com/7InDr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7InDr.png" alt="enter image description here"></a>
  I tried running the code below but it didnt work : </p>
  
  <pre><code>ax = self.canvas.figure.add_subplot(111)
  ax.spines['top'].set_visible(True)
  ax.spines['right'].set_visible(True)
  ax.spines['bottom'].set_visible(True)
  ax.spines['left'].set_visible(True)
  ax.plot(diff)
  </code></pre>
  
  <p>I also tried : </p>
  
  <pre><code>plt.tight_layout()
  </code></pre>
  
  <p>but it generates this error :</p>
  
  <pre><code>&gt; File "runme.py", line 54, in autocorr_function
  &gt;     plt.tight_layout()   File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line
  &gt; 1406, in tight_layout
  &gt;     fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)   File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py",
  &gt; line 1753, in tight_layout
  &gt;     rect=rect)   File "/usr/local/lib/python2.7/dist-packages/matplotlib/tight_layout.py",
  &gt; line 326, in get_tight_layout_figure
  &gt;     max_nrows = max(nrows_list) ValueError: max() arg is an empty sequence
  </code></pre>
  
  <p>Your help would be appreciated, thank you.</p>
  
  <p>EDIT : Here's the code of the canvas :</p>
  
  <pre><code>from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
  
  import matplotlib.pyplot as plt from PyQt4 import QtGui 
  
  class   Canvas(FigureCanvas):
  
       def __init__(self, parent=None):
           self.figure = plt.figure()     #plt.tight_layout(pad=4)
           FigureCanvas.__init__(self, self.figure)
           self.setParent(parent)
           FigureCanvas.setSizePolicy(self,
                                  QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Expanding)
           FigureCanvas.updateGeometry(self)
  </code></pre>