When I use numbered colors in wordcloud2, nothing is displayed.
library(wordcloud2)
wordcloud2(demoFreq,color='blue1')
Color names without numbers are ok. E.g. color='blue'
What am I missing?
When I use numbered colors in wordcloud2, nothing is displayed.
library(wordcloud2)
wordcloud2(demoFreq,color='blue1')
Color names without numbers are ok. E.g. color='blue'
What am I missing?
Since the word cloud is being rendered in HTML, you need to use html colors. blue1
is an R color, not HTML, so you need to convert it to a hex value color. the R function col2rgb
will give an RGB triple, but that will not work with HTML. You need to convert the triple to a hex value. You can do that using rgb
. However, rgb
expects 3 columns, not a column of 3 values, so use t
to transpose the RGB values.
rgb(t(col2rgb("blue1")), maxColorValue = 255)
[1] "#0000FF"
Now you can successfully call wordcloud2
wordcloud2(demoFreq, color=rgb(t(col2rgb("blue1")), maxColorValue = 255))
Probably HTML color codes are meant by "numbered colors", e.g.
wordcloud2(demoFreq, color= "#0080CC")
When "blue1"
is not defined anywhere wordcloud2()
has no color to use. But you could define one yourself.
library(wordcloud2)
blue1 <- "#0080CC"
wordcloud2(demoFreq, color= blue1)
Note that there are no quotes ""
in this case.
There are more color names available here. The package itself defines 'random-dark'
and 'random-light'
in addition.
Edit: According to @GW5's comment use following code to obtain exactly the desired "blue1"
as a workaround:
blue1 <- colors()[27]
wordcloud2(demoFreq, color= blue1)