title: Why does this confusion matrix (matplotlib) look squished in Jupyter Notebook?
body: <p>I'm running the code below for a confusion matrix. The output looked great until I reset the notebook kernal. I didn't change the code, but now it looks squished (Fig 1). It corrects when I delete the plt.yticks line (Fig 2), but I want those labels. This is probably simple, but I'm new to Python.</p>
  
  <pre><code>import itertools
  def plot_confusion_matrix(cm, classes,
                            normalize=False,
                            title='Confusion Matrix',
                            cmap=plt.cm.Blues):
      """
      This function prints and plots the confusion matrix.
      Normalization can be applied by setting `normalize=True`.
      Source: http://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html
      """
      if normalize:
          cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
          print("Normalized confusion matrix")
      else:
          print('Confusion matrix, without normalization')
  
      print(cm)
  
      # Plot the confusion matrix
      plt.figure(figsize = (6, 6))
      plt.imshow(cm, interpolation='nearest', cmap=cmap)
      plt.title(title, size = 25)
      plt.colorbar(aspect=5)
      tick_marks = np.arange(len(classes))
      plt.xticks(tick_marks, classes, rotation=45, size = 12)
      plt.yticks(tick_marks, classes, size = 12)
  
      fmt = '.2f' if normalize else 'd'
      thresh = cm.max() / 2.
  
      # Labeling the plot
      for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
          plt.text(j, i, format(cm[i, j], fmt), fontsize = 20,
                   horizontalalignment="center",
                   color="white" if cm[i, j] &gt; thresh else "black")
  
      plt.grid(False)
      plt.tight_layout()
      plt.ylabel('Actual label', size = 15)
      plt.xlabel('Predicted label', size = 15)
  
  cm = confusion_matrix(y_test, y_pred)
  plot_confusion_matrix(cm, classes = ['Good Mental Health', 'Poor Mental Health'],
                        title = 'Confusion Matrix')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AgZNm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AgZNm.jpg" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QAgtq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QAgtq.jpg" alt="enter image description here"></a></p>