我喜欢个性化我的图片与水印的背景JPG或PNG图像。我使用wordcloud2、RStudio,文本可以是任意的。也欢迎使用wordcloud1帮助。
如果wordcloud2不能像我注意到的那样与字母、图像等一起使用,wordcloud1可能是一个有趣的解决方案。
img <- readPNG(system.file("img", "Rlogo.png", package="png"), native=TRUE)
library(wordcloud2)
wordcloud2(data = demoFreq)例如,使用R标志作为水印我希望水印"R“出现在单词expect的背景中。
发布于 2019-02-20 16:25:55
以下是实现该任务的一种方法。当您使用wordcloud2()时,有一个参数可以指定背景色(即backgroundColor)。我原以为backgroundColor = "transparent"会是个不错的选择。但是输出文件的背景似乎是白色的。)我可能做错了什么。如果是这样,请纠正我。)所以我最终使用GIMP来编辑词云。你甚至可以使用该软件在背景图像上叠加wordcloud。但是,我选择使用magick包来使用R。要使背景颜色透明,请参阅this question。该问题包含您需要执行的所有步骤。
一旦wordcloud准备就绪,你就可以运行下面的代码了。我希望这对你有帮助。
library(magick)
# Import images
words <- image_read("my_wordcloud.png")
logo <- image_read("R.svg")
# Stack layers
img <- c(logo, words)
img <- image_scale(img, "500x500")
image_info(img)
# combine the layers into a single image
foo <- image_flatten(img)
# Save the image
image_write(foo, path = "so.png", format = "png")

https://stackoverflow.com/questions/54765891
复制相似问题