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

标签 r image cowplot

我想在 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/

相关文章:

r - 将共享图例与绘图网格的中心对齐(使用牛图)

r - 比较时格式化的 round() 函数输出不等于实际值

r - knitr:运行Rmarkdown文档中的所有 block

r - 在R,RStudio中同时显示和保存绘图

Javascript 加载图片

javascript - 在点击上传 javascript/jquery 之前显示图像

r - 添加一个变量以指定多个变量中哪一个等于某个值

c# - 透明图形缓冲区清除?

r - 使用 cowplot 将 x 轴切换到顶部时的左对齐轴标签

r - ggplot : Boxplot by several categorical variables