title: _tkinter.TclError: couldn't connect to display "localhost:10.0" when using wordcloud
body: <p>I'm getting <code>_tkinter.TclError: couldn't connect to display "localhost:10.0"</code> when SSH'ing (with <code>-X</code>) into my Ubuntu 16.04 servers, running this script</p>
  
  <pre><code>from os import path
  from wordcloud import WordCloud
  import matplotlib as mpl
  import matplotlib.pyplot as plt
  
  mpl.use('Agg')
  d = path.dirname(__file__)
  
  text = open(path.join(d, 'words.txt')).read()
  wordcloud = WordCloud().generate(text)
  
  # Configure plot
  plt.imshow(wordcloud, interpolation='bilinear')
  plt.axis("off")
  
  # lower max_font_size
  wordcloud = WordCloud(max_font_size=40).generate(text)
  plt.figure()
  plt.imshow(wordcloud, interpolation="bilinear")
  plt.axis("off")
  
  plt.savefig("comments.png")
  </code></pre>
  
  <p>This script is using Wordcloud (<a href="https://github.com/amueller/word_cloud/" rel="noreferrer">https://github.com/amueller/word_cloud/</a>). <code>words.txt</code> is a bunch of words that I intend to turn into a wordcloud. What's supposed to happen is the cloud gets saved as comments.png (but not displayed) on the server I'm ssh'ing into. </p>