Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用grid.arrange()在同一页面中绘制多个绘图_R_Ggplot2 - Fatal编程技术网

使用grid.arrange()在同一页面中绘制多个绘图

使用grid.arrange()在同一页面中绘制多个绘图,r,ggplot2,R,Ggplot2,我需要安排在同一个pdf页面中使用ggplots stat_binhex生成的4个绘图 densityplots<-lapply(1:breaks, function(i){ dataplot<-ggplot(data,aes(x=data$A, y=data$B)) + stat_binhex() + xlim(-2,2) + ylim(-2,2) return(dataplot) }) 我发现了错误: Error in data.frame(x = c(-1.34537

我需要安排在同一个pdf页面中使用ggplots stat_binhex生成的4个绘图

densityplots<-lapply(1:breaks, function(i){
  dataplot<-ggplot(data,aes(x=data$A, y=data$B)) + stat_binhex() + xlim(-2,2) + ylim(-2,2)
  return(dataplot)
})
我发现了错误:

Error in data.frame(x = c(-1.34537238683369e-05, 0.0053077854, 0.0011863784,  : 
  arguments imply differing number of rows: 11508, 9864
用于生成图的数据集A和B的行数不同。如何在同一页上绘制它们


谢谢大家!

不要在aes中使用$。语法是aesx=A,y=B和ggplot,然后在传递给数据参数的data.frame中查找这些变量。谢谢Roland!解决了的!
Error in data.frame(x = c(-1.34537238683369e-05, 0.0053077854, 0.0011863784,  : 
  arguments imply differing number of rows: 11508, 9864