小编Evi*_*man的帖子

如何创建图形和图像以在 R 中的同一面板上显示

我是 R 新手,并尝试使用 R 在同一页面上显示图形和图像。我尝试使用library(ggpubr)ggarrange()运行。

导入我使用的图像library(png)readPNG()导入我的图像。

我想要的最终结果是这样的:

在此输入图像描述

我用来创建面板的代码是:

library(ggpubr)
library(png)

data("ToothGrowth")

bxp <- ggboxplot(ToothGrowth, x = "dose", y = "len",
                 color = "dose", palette = "jco")
dp <- ggdotplot(ToothGrowth, x = "dose", y = "len",
                color = "dose", palette = "jco", binwidth = 1)

img1 <- readPNG("image1.png")
img2 <- readPNG("image2.png")

im_A <- ggplot() + background_image(img1) # tried to insert the image as background.. there must be a better way
im_B <- ggplot() …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 ggpubr

6
推荐指数
1
解决办法
2906
查看次数

标签 统计

ggplot2 ×1

ggpubr ×1

r ×1