"pythonic生物人"的第110篇分享

。
本文系统介绍ggplot2的坐标系(coord)、分面(facet)。
本文目录
9、坐标系(coord)
线性坐标系
非线性坐标系
10、分面(facet)
Facet wrap
Facet grid
9、坐标系(coord)
线性坐标系
base geom_point() +
geom_smooth()
p1 p2 5, 7))#设置坐标轴显示范围,突出显示图中某一部分
p3 geom_point() +
geom_smooth()
p4 geom_point() +
geom_smooth() +
coord_flip()#最大程度拟合
p5 geom_point() +
geom_smooth() +
coord_fixed()#x y轴切换
p6 3)
ggsave("scale26.png", p6, width = 6.5, height = 5)
非线性坐标系
10、分面(facet)
Facets divide a plot into subplots based on the values of one or more discrete variables, 分三类。
facet_null(): a single plot, the default.facet_wrap(): “wraps” a 1d ribbon of panels into 2d.facet_grid(): produces a 2d grid of panels defined by variables which form the rows and columns.
Facet wrap
options(repr.plot.width = 4.5, repr.plot.height = 5, repr.plot.res = 300)
mpg2 5 & drv %in% c("4", "f") & class != "2seater")
base geom_blank() +
xlab(NULL) +
ylab(NULL)
p1 3)#三列展示
p2 3, as.table = FALSE)
p3 3)#三行展示
p4 3, dir = "v")#
p5 2)
ggsave("scale28.png", p5, width = 6.5, height = 5)
Facet grid
#效果见图
options(repr.plot.width = 4.5, repr.plot.height = 5, repr.plot.res = 300)
p1 p2 #通过cyl按列绘图
p3 #通过drv按行绘图
p4 #通过drv按行绘图,通过cyl按列绘图
p5 2)
ggsave("scale29.png", p5, width = 6.5, height = 5)
本文结束,更多好文:
- Python可视化|Matplotlib39-Matplotlib 1.4W+字教程(珍藏版)
- Python可视化|Matplotlib&Seaborn36(完结篇)
- python3基础12详解模块和包(库)|构建|使用
- Perl基础系列合集
- NGS各种组学建库原理(图解)

有用请“点赞”“在看”“分享”


有意见请移步到QQ群629562529反馈,一起进步哈!


739

被折叠的 条评论
为什么被折叠?



