【问题标题】:R corrplot produces empty plotR corrplot 产生空图
【发布时间】:2014-12-04 17:45:31
【问题描述】:

我有一个包含 ~750k 元素的矩阵,我想用 corrplot 绘制它。它绘制它没有错误,但它产生的情节是空的,只有色标。使用命令行 R 时,它会在“Quartz 2”窗口中显示绘图,但几秒钟后就会消失。是什么赋予了?

library("corrplot")
mat <- matrix(data = rexp(200, rate = 10), nrow = 800, ncol = 800)
col1 <- colorRampPalette(c("#00007f", "#00007f", "#00007f", "#00007f", "blue", "cyan", "#00cc00", "yellow", "#FF7F00", "red"), interpolate = "linear", alpha = TRUE) 
corrplot(splotMat, is.corr = FALSE, method = "color", tl.pos = "n", col = col1(100), cl.lim = c(-0.14, 1))

【问题讨论】:

  • 请给出一个最小的工作示例,例如描述here。首先,提供一小部分矩阵会有所帮助,例如 dput(Mat[1:20,1:20])
  • 好的。我已经更新了代码。谢谢。

标签: r plot r-corrplot


【解决方案1】:

我认为问题不在于代码,而在于绘图窗口的分辨率(即亚像素绘图)。我玩过尺寸低于 500x500 的矩阵,它在我的笔记本电脑屏幕上显示得很好。在 550 左右,我把它弄丢了(如你所见,空白)。当我将窗口移到更大的显示器上时,我最多可以绘制 800 个(尽管确实需要一段时间)。

为了查看它是否提供更高分辨率的渲染,我将其转储为 PDF 并放大:

## your data
library("corrplot")
mat <- matrix(data = rexp(200, rate = 10), nrow = 800, ncol = 800)
col1 <- colorRampPalette(c("#00007f", "#00007f", "#00007f", "#00007f", "blue",
                           "cyan", "#00cc00", "yellow", "#FF7F00", "red"),
                         interpolate = "linear", alpha = TRUE) 
## demonstration
pdf("foo.pdf", width = 20, height = 20)
corrplot(mat, is.corr = FALSE, method = "color",
         tl.pos = "n", col = col1(100), cl.lim = c(-0.14, 1))
dev.off()

该文件将相当大(~8MB),但您可以放大并查看各个单元格的颜色(可能很淡)。

【讨论】:

  • 感谢您的回复。我想要它最初吐出并擦除的图像。我只能截个屏幕。但我似乎必须逐个像素地绘制绘图。伟大的。还是谢谢。
  • 您始终可以使用png(...) 而不是pdf(...),但您需要将分辨率和大小设置得足够大,以便提供所需的像素(例如,png("foo.png", res = 600, width = 6, height = 6, units = "in"))。
  • 更改...png("foo.png", res = 600, width = 20, height = 20, units = "in") 有效,6 英寸无效。提高 res、宽度/高度,或两者兼而有之。
  • 使用 png 无法按预期工作。在图像消失之前,它看起来像这样link,但使用 png 设备使图像像这样link。有任何想法吗?谢谢。
  • 我不确定为什么,但绘制情节的第一阶段看起来像是没有应用 alpha 的颜色,并且与您的第一个链接相匹配。第二个链接看起来像我得到的。你期待看到什么?
猜你喜欢
  • 2017-03-06
  • 2021-06-17
  • 2017-03-20
  • 2013-01-23
  • 1970-01-01
  • 2020-11-23
  • 2015-03-22
  • 2021-10-02
  • 2014-08-07
相关资源
最近更新 更多