title: AttributeError: 'AxesSubplot' object has no attribute 'xlabel'
body: <p>l
  have to plot to save after a for loop where l get all the values . Here is my code .
  However l get an error at the line: <code>fig1, ax1 = plt.subplots()</code>:</p>
  
  <pre><code>g_i= []
  g_train_loss= []
  g_valid_loss=[]
  g_train_accuracy=[]
  g_valid_accuracy=[]
  for epoch in range(niter):
          #other computations
          g_i = np.append(g_i, epoch)
          g_train_loss = np.append(g_train_loss, loss_avg.val())
          g_train_accuracy = np.append(g_train_accuracy,accuracy_train)
          g_valid_loss = np.append(g_valid_loss, cost_val)
          g_valid_accuracy = np.append(g_valid_accuracy, accuracy_valid)
  fig1, ax1 = plt.subplots()
  fig2, ax2 = plt.subplots()
  ax1.plot(g_i,g_train_loss,label='train_loss')
  ax1.plot(g_i,g_valid_loss,label='valid_loss')
  ax1.xlabel("epoch")
  ax1.ylabel("loss")
  f1=ax1.figure()
  f1.savefig('loss.png', bbox_inches='tight')
  ax2.plot(g_i,g_train_accuracy,label='train_acc')
  ax2.plot(g_i,g_train_accuracy,label='valid_acc')
  ax2.xlabel("epoch")
  ax2.ylabel("accuracy")
  f2=ax2.figure()
  f2.savefig('acc.png', bbox_inches='tight')
  </code></pre>
  
  <p>l get the following error at</p>
  
  <pre><code>fig1, ax1 = plt.subplots()
  </code></pre>
  
  <p>which is :</p>
  
  <pre><code>/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 144, in _create_qApp
      raise RuntimeError('Invalid DISPLAY variable')
  RuntimeError: Invalid DISPLAY variable
  </code></pre>
  
  <p>Edit1 :
  l'm usisng ubuntu 16.04 aws amazon server
  l did the following : </p>
  
  <pre><code>import matplotlib
  matplotlib.use('agg')
  import matplotlib.pyplot as plt
  </code></pre>
  
  <p>then l get the following new error : 
      ax1.xlabel("epoch")
  AttributeError: 'AxesSubplot' object has no attribute 'xlabel'</p>