I have some working R code that generates a tag cloud from a term-document matrix.
Now I want to create a whole bunch of tag clouds from many documents, and to inspect them visually at a later time. To know which document(s)/corpus the tag-cloud picture belongs to, I'd lke to add a title to the generated graphic. How do I do that?
Maybe this is obvious, but I'm still a beginner with R graphics.
My own corpus is too big to list it here, but the code from this SO question (combined with the code form the accepted answer from SO user Andrie can be used: Spaces in wordcloud I want to add a custom title and some more custom text to a picture like this
The
wordcloud()
function fills the entire plot. That means you need to reserve space on your graphics device for the title before plotting.Since
wordcloud
make use of base grapics, you can do this with eitherpar(mfrow=...)
orlayout()
. Then create the plot title withtext()
.I illustrate with
layout()
, adapting the example in?wordcloud
:This generates:
One idea is to import the images , and save again them using
grid.raster
, and add the titile usinggrid.text
. For example: