Group Abstract Group Abstract

Message Boards Message Boards

Create a simple word cloud?

Posted 10 years ago

Hello everyone,

I'd like to create a simple word cloud to use as one of a number of programming examples for my students. I obviously do not want to use Mathematica's slick WordCloud function. Here is what I have so far, which isn't very much: the placement of the styled word Howdy at position {4, 4} in a graphics object whose size is 288.

Graphics[Style[Text["Howdy", {4, 4}], FontFamily -> "Palatino", 
  FontSize -> 22, FontColor -> Orange], ImageSize -> 288]

Suppose that Howdy is the most frequent word in my text, so that, at 22 points, it must display as the biggest in my word cloud. The other, less frequent words will be displayed around it in smaller fonts. That's where I'm stuck. I realize that this is an arrangement or packaging problem, where I need to arrange all of the words in the graphics area in such a way that they do not overlap. But in order to do this I need the location of Howdy as a rectangle that most snugly encloses it (top-left, top-right, bottom-left, bottom right) so that I can place the other words. How should I approach this? Perhaps I should be using something other than the Graphics function?

Regards,

Gregory

POSTED BY: Gregory Lypny
5 Replies
Posted 10 years ago

Hi Henrik,

Thanks for the reference to Frank Kampas' work on packaging ellipses. I downloaded the paper. It looks fascinating but it will be a tough read!

Regards,

Gregory

POSTED BY: Gregory Lypny
Posted 10 years ago

Hi Louis,

Thank you for your thorough and thoughtful approach. I didn't know about ImageCrop and ImageDimensions because I don't do a lot of work with graphics other than financial plots. It is those two functions that will let me deal with the problem of establishing the location of each word as a rectangular graphic with respect to the coordinates of their corners. Good stuff. I also like your approach of starting students off with building word towers!

Thanks again,

Gregory

POSTED BY: Gregory Lypny

I learned in this discussion that it should/can be treated as a packing problem. See e.g. interesting contributions made by @Frank Kampas.

POSTED BY: Henrik Schachner
Posted 10 years ago

Create a simple word cloud?

POSTED BY: Louis Godwin
Posted 10 years ago
Attachments:
POSTED BY: Louis Godwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard