美文网首页
二维码生成器(R)

二维码生成器(R)

作者: 挽山 | 来源:发表于2020-02-28 15:43 被阅读0次
#install.packages("ggimage")
#install.packages("devtools")
#install.packages("qrcode")

library(ggimage)
library(devtools)
library(qrcode)
BiocManager::install("ggtree")

devtools::install_github("GuangchuangYu/yyplot")
library(yyplot)

require(ggplot2)
require(ggimage)
require(yyplot)

#把链接变成二维码
ggqrcode("https://mp.weixin.qq.com/s/TMmsOsEn0wV9yXKOLma3Rw")

#实验室楼上有个冰箱,外面贴着好多二维码,扫一下就知道冰箱某一格放的是什么东西,详细介绍什么的
ggqrcode("I love you")

#高级
#首先构建一个包含图像地址的ggplot对象,其中图片层为geom_image, 背景主题为无,也就是theme_void().
d <- data.frame(x=1, y=1,
                img="http://kemono-friends.jp/wp-content/themes/kemono-friends/assets/zoo/img/detail/001/chara.png")
p <- ggplot(d, aes(x,y)) + geom_image(aes(image=img), size=Inf) + theme_void()

#添加上二维码的图层,颜色为蓝色,透明度为80%,
p2 <- ggqrcode("http://mp.weixin.qq.com/s/oLgpTGdQgcka-OD757_3lA", "blue", alpha=.8)
p + geom_subview(p2, width=Inf, height=Inf, x=1, y=1)

#将我们的logo直接用ggimage添加到二维码的中心
pg <- ggqrcode("https://mp.weixin.qq.com/s/TMmsOsEn0wV9yXKOLma3Rw")
d <- data.frame(x=15, y=15,    
                img="https://guangchuangyu.github.io/blog_images/gc.png")
pg + geom_image(aes(x,y, image=img), data=d, size=.2)

相关文章

网友评论

      本文标题:二维码生成器(R)

      本文链接:https://www.haomeiwen.com/subject/nxelhhtx.html