Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a wordcloud with matplotlib

Im trying to create a wordcloud with Matplotlib. Essentially I am able to put text at arbitrary locations in my grid, but need to work out a way of preventing them from colliding. In relation to this I am stuck on two questions:

  1. What is the unit of fontsize?

  2. How do I transfer the "fontsize" of the text to units in my figure, so I can mark them as used? That is, how do I know how much space each letter will take up in my grid? Ideally I would not have to mark out a whole rectangle around each word, but only the pixels they actually use as available for other words.

like image 292
user1603472 Avatar asked Jun 30 '26 14:06

user1603472


1 Answers

I'm not sure about how to do it with matplotlib but I have used this in the past: http://peekaboo-vision.blogspot.co.uk/2012/11/a-wordcloud-in-python.html