ggplot2 一页多图
来源:互联网 发布:python中 变量类型 编辑:程序博客网 时间:2024/05/07 01:48
本案例文本来自于公众号:数据小魔方
载入包
library(ggplot2)
library(grid)
定义图表
chart1 <- ggplot(mtcars,aes(mpg,wt,colour=factor(cyl)))+geom_point()
chart2 <- ggplot(diamonds, aes(carat,depth,colour=color))+geom_point()
chart3 <- ggplot(diamonds,aes(carat,depth,colour=color))+geom_point()+
facet_grid(.~color)
- 图三表示以color进行分面
新建图片版面
grid.newpage()
版面分成2*2矩阵
pushViewport(viewport(layout=grid.layout(2,2)))
定义图表的布局规则
vplayout <- function(x,y){viewport(layout.pos.row = x,layout.pos.col = y)}
- 制定画布的行显示图表的x轴,列显示图表的y轴
画图
print(chart3,vp=vplayout(1,1:2))
print(chart2,vp=vplayout(2,1))
print(chart1,vp=vplayout(2,2))
- 将(1,1) (1,2)的位置画上图chart3
- 将(2,1)的位置画上图chart2
- 将(2,2)的位置画上图chart1
阅读全文
0 0
- ggplot2 一页多图
- ggplot2 一页多图
- ggplot2 3.0 分面、一页多图
- ggplot2-分面(facet) 一页多图
- ggplot2-一页多图(不同来源, 灵活绘制)
- ggplot2-一页多图(不同来源, 灵活绘制)(转载)
- ggplot2-分面(facet) 一页多图(转载)
- ggplot2实现多图合并
- 一页多图
- R ggplot2 做图
- R -ggplot2 气泡图
- ggplot2线型图
- ggplot2绘制条形图
- R ggplot2条形图
- R ggplot2线性图
- ggplot2
- ggplot2
- ggplot2
- 搜索制作
- LINUX 双版本python numpy安装及版本切换
- 【Linux】使用VMware安装CentOS
- Jsp内置对象
- python 连接MySQL数据库报错的解决办法
- ggplot2 一页多图
- 最大团模板
- Sequence_postfix expression(后缀表达式求值)
- 豪迪QQ群发营销软件
- Coursera Using python to access Web data
- Spring Integration 系统集成
- Android 了解1G 2G 3G 知识
- ResourceManager(三)—— Request,ResourceAsyncOperation
- 如何走进Tomcat源码的探究