【发布时间】:2018-05-21 16:17:11
【问题描述】:
我使用以下代码在 ggplot2 中创建了一个条形图。
g <- ggplot(mpg, aes(class))
# Number of cars in each class:
g + geom_bar()
我使用诸如
之类的代码创建了一个图像对象img <- png::readPNG("./watermark.png")
rast <- grid::rasterGrob(img, interpolate = T)
现在我正在尝试使用诸如
之类的命令将此图像粘贴到绘图上g + annotation_custom(rast, xmin=-Inf, xmax=Inf,ymin=-Inf,ymax=Inf)
创建以下情节 https://imgur.com/a/epOcDQV
我了解 annotation_custom 中的 x 和 y 坐标与绘制在 x 和 y 轴上的数据相关。
在我的情况下,我在 X 轴上有离散数据,并想将此图像粘贴到右上角,请有人建议我如何做到这一点。
【问题讨论】: