gpt4 book ai didi

r - 在 R 中使用 cowplot 对齐 image() 图

转载 作者:行者123 更新时间:2023-12-01 13:17:53 25 4
gpt4 key购买 nike

我想在 R 中对齐两个图,这些图是使用 image() 函数生成的。

示例代码:

# Load package
library(cowplot)

# Plot sample image
image <- image(matrix(rnorm(1000), 100,100))

# Align plots
plot_grid(image, image)

但是,当我这样做时,情节不会出现。我错过了什么吗?或者 cowplot 不能处理图像函数生成的图吗?

最佳答案

您需要做一些工作来将它们存储在您的环境中。如果您检查 image,您会看到它是 NULL。所以你必须记录它,然后绘制它。

p <- recordPlot()
plot.new()
image(matrix(rnorm(1000), 100,100))
p

plot_grid(p, p, nrow = 2)

enter image description here

关于r - 在 R 中使用 cowplot 对齐 image() 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52976015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com