我想在 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
示例檔案:
- bg.png:
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/338260.html上一篇:將圖例插入不同的圖形
下一篇:將徽標動態添加到R圖中
