R:omi和mar返回时出现xlim错误

R:omi和mar返回时出现xlim错误,r,plot,margin,axis,R,Plot,Margin,Axis,我想将绘图的图像保存为png文件;但是,它会切断轴标签。因此,我试图通过设置“omi”和“mar”来留下更大的空白,但似乎不起作用。添加更多像素也不起作用。如果cex.lab的值较小,则轴将可见,但小得难以理解 也许这个错误是愚蠢的,但我无法理解 png(filename = "CarTheftForeigners.png", width = 1120, height = 646, units = "px", pointsize = 12, bg = "white", res = NA, fam

我想将绘图的图像保存为png文件;但是,它会切断轴标签。因此,我试图通过设置“omi”和“mar”来留下更大的空白,但似乎不起作用。添加更多像素也不起作用。如果cex.lab的值较小,则轴将可见,但小得难以理解

也许这个错误是愚蠢的,但我无法理解

png(filename = "CarTheftForeigners.png",
width = 1120, height = 646, units = "px", pointsize = 12,
bg = "white", res = NA, family = "", restoreConsole = TRUE,
type = c("windows", "cairo", "cairo-png")
)
plot(Table$Car.Theft,Table$Foreigners, 
 type="p", pch=20, col="red",
 main="Correlation of the Rate of Car Theft and Rate of Foreigners", cex.main=2, 
 xlab="Rate of Car Thefts",
 ylab="Rate of Foreigners", cex.lab=2,
 par(omi=c(1,1,1,1)+0.1))
abline(reg=lm(Foreigners ~ Car.Theft, data=Table),col="blue")
dev.off()
无论我为omi或mar添加什么值,我总是会得到错误:

Fehler in plot.window(...) : ungültiger 'xlim' Wert
这是德语,表示xlim值无效

谢谢你的帮助

不能在
绘图
内调用
par()
。在
plot
之前尝试发出
par
调用

这成功:

png(filename = "CarTheftForeigners.png",
    width = 1120, height = 646, units = "px", pointsize = 12)
  par(omi=c(1,1,1,1)+0.1)
  plot(1:10, 1:10)
dev.off()
这并不是:

png(filename = "CarTheftForeigners.png",
     width = 1120, height = 646, units = "px", pointsize = 12);
plot(1:10, 1:10 , type="p",  par(omi=c(1,1,1,1)+0.1))
#   Error in plot.window(...) : invalid 'xlim' value
dev.off()
<>但是,你真的想在PROTE()中使用PAR调用,你可以把这个值命名为“代码> OMI<代码>,这样可以防止发生错误的位置匹配。
png(filename = "CarTheftForeigners.png",
     width = 1120, height = 646, units = "px", pointsize = 12);
   plot(1:10, 1:10 , type="p",  omi = par(omi=c(1,1,1,1)+0.1))
dev.off()

出现这种有点神秘的错误消息的原因是
plot
试图将
par(omi=c(1,1,1,1)+0.1)
中的值与
plot.default
的参数列表中的第一个不匹配的参数值相匹配,在这种情况下,参数列表是
xlim
。所以你的意思是在
png(…)
之后,我把
par(omi=c)放在(1,1,1,1)+0.1)
然后是
?对。会变得清晰的。哈哈,你太棒了!现在外缘完美了!谢谢!