【发布时间】:2021-12-10 09:46:28
【问题描述】:
我想在 ggplot2 图上堆叠 PNG 图像。其中一个 png 具有 alpha/透明度信息,但它被忽略了。
如何在 bg.png 顶部添加第二张图片 (image1.png),以便保留透明度并且在黄色背景上仅显示黑色文本?
示例
library(ggplot2)
library(png)
library(patchwork)
img1 <- readPNG("bg.png", native = TRUE)
img2 <- readPNG("image1.png", native = TRUE)
ggp <- ggplot(data.frame()) +
geom_point() +
theme_nothing() +
inset_element(p = img1,
left = 0,
bottom = 0,
right = 1,
top = 1,
align_to = "full") +
inset_element(p = img2,
left = 0,
bottom = 0,
right = 0.5,
top = 0.5,
align_to = "full")
ggp
示例文件:
【问题讨论】:
-
不确定,但这可能是相关的:stackoverflow.com/a/64156644/6851825