title: Creating wordcloud using python
body: <p>I am trying to create a  <strong>wordcloud</strong> in <strong>python</strong> after cleaning <strong>text file</strong> ,</p>
  
  <p>I got the required results i.e words which are mostly used in the text file but unable to plot.</p>
  
  <p>My code:</p>
  
  <pre><code>import collections
  from wordcloud import WordCloud
  import matplotlib.pyplot as plt
  
  file = open('example.txt', encoding = 'utf8' )
  stopwords = set(line.strip() for line in open('stopwords'))
  wordcount = {}
  
  for word in file.read().split():
      word = word.lower()
      word = word.replace(".","")
      word = word.replace(",","")
      word = word.replace("\"","")
      word = word.replace("“","")
      if word not in stopwords:
          if word not in wordcount:
              wordcount[word] = 1
          else:
              wordcount[word] += 1
  
  d = collections.Counter(wordcount)
  for word, count in d.most_common(10):
      print(word , ":", count)
  
  #wordcloud = WordCloud().generate(text)
  #fig = plt.figure()
  #fig.set_figwidth(14)
  #fig.set_figheight(18)
  
  #plt.imshow(wordcloud.recolor(color_func=grey_color, random_state=3))
  #plt.title(title, color=fontcolor, size=30, y=1.01)
  #plt.annotate(footer, xy=(0, -.025), xycoords='axes fraction', fontsize=infosize, color=fontcolor)
  #plt.axis('off')
  #plt.show()
  </code></pre>
  
  <p><strong>Edit</strong>:
  Plotted the wordcloud with following <strong>code</strong>:</p>
  
  <pre><code>wordcloud = WordCloud(background_color='white',
                            width=1200,
                            height=1000
                           ).generate((d.most_common(10)))
  
  
  plt.imshow(wordcloud)
  plt.axis('off')
  plt.show()
  </code></pre>
  
  <p>But getting <code>TypeError: expected string or buffer</code></p>
  
  <p>when I tried the above code with <code>.generate(str(d.most_common(10)))</code></p>
  
  <p>The <strong>wordcloud</strong> formed is showing <strong>apostrophe(')</strong> sign after several words</p>
  
  <blockquote>
    <p>using Jupyter Notebook | python3 | Ipython</p>
  </blockquote>