【问题标题】:Figure margins too large when trying to use layout()尝试使用 layout() 时图边距太大
【发布时间】:2016-11-04 06:46:07
【问题描述】:

我有这个数据集

wine <-read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data",sep=",")
attach(wine)

我想使用布局函数来提示六个散点图,每个散点图都带有上面的直方图,但是当试图将第一个带有自己的直方图的散点图放在上面时,会发生此错误:

> m<-rbind(c(2,4,6),c(1,3,5),c(8,10,12),c(7,9,11))
> layout.show(layout(m))
> layout(m)
> plot(V2[1:25]~V5[1:25]);with(wine, hist(V5))
Error in plot.new() : figure margins too large

我尝试使用png("1.png",800,600),文件被创建,但它告诉我我没有权限查看文件的内容。

【问题讨论】:

  • 尝试增加设备的尺寸。
  • 我得到了同样的结果
  • 你可以简单地在你的 R Studio 中手动调整绘图窗口......这样就可以完成这项工作。
  • 或者简单地减少与margin相关的参数,例如par(mar = c(3, 3, 1.5, 0.4), mgp = c(1.5, 0.4, 0), tck = - 0.05)

标签: r plot visualization


【解决方案1】:

增加设备的尺寸。这在我的系统上运行良好:

png("test.png", width = 1000, height = 1000)

layout(m)
plot(V2 ~ V5, data = wine[1:25,])
with(wine, hist(V5))

dev.off() #you need to close the device to open the file in other software

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 2015-10-08
    相关资源
    最近更新 更多