2

When I want to export a wordcloud2 picture, the wordcloud seems to be recalculated and looks very different from the one in the viewer.

How can I prevent R from creating another picture?

library(wordcloud2)
wordcloud2(demoFreq[demoFreq$freq>7,],minRotation = 0, maxRotation = 0)

Pictures: https://drive.switch.ch/index.php/s/8WIkGEM88wd4UXc

Bartli
  • 315
  • 2
  • 11

2 Answers2

1

you should just add shuffle = FALSE in your function and in case you want to control the colors you can create a color palette using the rainbowfunction with the number of rows of your data input:

dataInput <- demoFreq[demoFreq$freq>7,]
my_colors <- rainbow(nrow(dataInput), start = 0.1) # check ?rainbow for more infos
wordcloud2(dataInput, minRotation = 0, maxRotation = 0, shuffle = F, color = my_colors)

gives you:

enter image description here

Hope this helps!

Codutie
  • 1,055
  • 13
  • 25
  • shuffle=FALSE keeps the words in their positions, but colors are changed. see https://drive.switch.ch/index.php/s/zli6r5BGy3AFQHp – Bartli Feb 08 '18 at 11:47
1

Adding shuffle = FALSE keeps the words in place. Defining nonrandom colors fixes the colors. Maybe with a color vector.

library(wordcloud2)
minfreq=10
upperpart= demoFreq[demoFreq$freq>minfreq,]
colorvector = rep(c('red','skyblue'), length.out=nrow(upperpart))   
wordcloud2(demoFreq[demoFreq$freq>minfreq,],minRotation = 0, 
            maxRotation = 0,shuffle=FALSE, color=colorvector)
Bartli
  • 315
  • 2
  • 11