Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font in Wordcloud package R

Tags:

r

word-cloud

The title is super self explanatory: I want to change the font (text type, bold) of the wordcloud package in R.

like image 874
sebastian-montero Avatar asked Apr 17 '17 22:04

sebastian-montero


People also ask

How do I change font size in word cloud?

You can change the size from the Words tab and the font for individual words.

How do I increase the size of word cloud in R?

If you include par(mar = rep(0, 4)) as a separate line immediately after the call to png you'll remove the margins, and the wordcloud will use all the available space. With this, and possibly tweaking the res parameter as suggested in the previous answer, you should get what you wanted.

What is wordcloud package in R?

A wordcloud (or tag cloud) is a visual representation of text data. Tags are usually single words, and the importance of each tag is shown with font size or color. In R , two packages allow to create wordclouds: Wordcloud and Wordcloud2 . Wordcloud2.


1 Answers

Use the family and font arguments:

library(wordcloud)
set.seed(1)
par(mfrow = c(1,2))
wordcloud(c(letters, LETTERS, 0:9), seq(1, 1000, len = 62), family = "serif", font = 3) 
wordcloud(c(letters, LETTERS, 0:9), seq(1, 1000, len = 62), family = "mono", font = 2)

enter image description here

See ?par under font and family for details. The extrafont package gives more options. You find many examples on SO.

like image 60
lukeA Avatar answered Sep 27 '22 22:09

lukeA