【问题标题】:How to add text to QR plot in R?如何在 R 中将文本添加到 QR 图?
【发布时间】:2020-09-16 07:53:48
【问题描述】:

我无法在我的二维码图中添加文本。我想在二维码底部添加一个注释来读取文本字符串(在本例中为“hello”)。当我运行下面的脚本时,我只得到没有任何注释的二维码。添加文本的最佳方式是什么?

# Libraries
library(qrcode)
library(ggplot2)

# QR String
string <- "test"

# Create QR Code
qrcode_label <- qrcode_gen(string, plotQRcode = TRUE)

# Annotate QR Code
#qrcode_label_annotated <- qrcode_label + text("hello")

# Save QR Code as PNG
ggsave("qrcode.png")

【问题讨论】:

    标签: r ggplot2 annotations qr-code barcode


    【解决方案1】:

    我就是这样做的。使用魔法。

    library(magick)
      library(rsvg)
      for (i in a) {
        print(i)
        ii=image_read(i)
        ii=image_annotate(ii,paste(tools::file_path_sans_ext(i)),  gravity= "south",size=20)
        print(ii)
        ##image_write(ii, path = "C:\\temp\\"&ii*".png", format = "png")
        image_write(ii, format <- "png", path = paste0(i, ""))

    【讨论】:

      猜你喜欢
      • 2017-05-26
      • 2017-10-03
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-11
      • 2022-01-10
      • 2017-04-28
      相关资源
      最近更新 更多