我有4种不同形式的21个变量(原始数据,平均值,log和log1p变换)。我想将它们绘制成一个大的(长)数字,其中包括4列和21行。我一直在玩这个论点很多......“宽度”和“高度”,单位改变,改变了分辨率尝试了png,jpeg,pdf ......一堆组合,但我无法得到想,我收到了那条旧消息:
Error in plot.new() : figure margins too large
有时候,我选择的值越来越差,我得到一个糟糕的数字,但后来我尝试打开它,窗口给我一条消息说我没有权限打开那个文件(???)。我被告知R必须写一个损坏的文件。我是R的新手,不知道还能做什么。我可以阅读任何提示或材料以获得解决方案? 这是我的代码...如果带有变量的数据框是相关的,请告诉我,我会想办法提供(这是巨大的)
#### 4 Histograms ####
#install.packages("png")
library(png)
jpeg(filename = "histograms.jpeg", width = 30, height = 60, units = "cm", pointsize = 12, bg = "white", res = 120)
par(pty = "m", mfrow = c(21, 4), cex.lab = 1 , cex.main = 0.9);
for(i in 1:ncol(climData_num_2)){
# All clim data
hist((climData_num_2)[,i],prob=TRUE,breaks =40, col ="thistle", xlab=(colnames((climData_num_2)[i])),main = paste("Histogram of" , colnames((climData_num_2)[i])))
curve(dnorm(x, mean=mean(((climData_num_2)[,i]),na.rm=TRUE), sd=sd(((climData_num_2)[,i]),na.rm=TRUE)), col="blue",lwd=2, add=TRUE)
lines(density(sort((climData_num_2)[,i])), col="red",lwd=2, add=TRUE)
# Average variables
hist((av_cdn_2)[,i],prob=TRUE,breaks =40, col ="thistle", xlab=(colnames((av_cdn_2)[i])),main = paste("Histogram of" , colnames((av_cdn_2)[i])))
curve(dnorm(x, mean=mean(((av_cdn_2)[,i]),na.rm=TRUE), sd=sd(((av_cdn_2)[,i]),na.rm=TRUE)), col="blue",lwd=2, add=TRUE)
lines(density(sort((av_cdn_2)[,i])), col="red",lwd=2, add=TRUE)
# Log transformed
hist(log(av_cdn_2)[,i],prob=TRUE,breaks =40, col ="thistle", xlab=(colnames((av_cdn_2)[i])),main = paste("Histogram of log" , colnames((av_cdn_2)[i])))
curve(dnorm(x, mean=mean((log(av_cdn_2)[,i]),na.rm=TRUE), sd=sd((log(av_cdn_2)[,i]),na.rm=TRUE)), col="blue",lwd=2, add=TRUE)
lines(density(sort(log(av_cdn_2)[,i])), col="red",lwd=2, add=TRUE)
# log1p transformed
hist(log1p(av_cdn_2)[,i],prob=TRUE,breaks =40, col ="thistle", xlab=(colnames((av_cdn_2)[i])),main = paste("Histogram of log1p" , colnames((av_cdn_2)[i])))
curve(dnorm(x, mean=mean(log1p((av_cdn_2)[,i]),na.rm=TRUE), sd=sd(log1p((av_cdn_2)[,i]),na.rm=TRUE)), col="blue",lwd=2, add=TRUE)
lines(density(sort(log1p(av_cdn_2[,i]))), col="red",lwd=2, add=TRUE)
}
dev.off()
所有建议都是相关的 提前谢谢
编辑:
运行代码的data.frames:
av_cdn_2<-data.frame(replicate(21,sample(0:1000,30,rep=TRUE)))
climData_num_2<-data.frame(replicate(21,sample(0:1000,30,rep=TRUE)))