首页 > 作文

R可视化12

更新时间:2023-04-03 20:33:41 阅读: 评论:0

本文系统介绍ggplot2的坐标系(coord)、分面(facet)。

本文目录

9、坐标系(coord)

线性坐标系

非线性坐标系

10、分面(facet)

Facet wrap

Facet grid

9、坐标系(coord

线性坐标系

ba <- ggplot(mpg, aes(displ, hwy)) +   geom_point() +   geom_smooth()p1 <- bap2 <- ba + coord_cartesian(xlim = c(5, 7))#设置坐标轴显示范围,突出显示图中某一部分p3 <- ggplot(mpg, aes(cty, displ)) +   geom_point() +   geom_smooth()p4 <- ggplot(mpg, aes(displ, cty)) +   geom_point() +   geom_smooth() +   coord_flip()#最大程度拟合p5 <- ggplot(mpg, aes(displ, cty)) +   已知直线lgeom_point()给女朋友讲的睡前故事 +   geom_smooth() +   coord_fixed()#x y轴切换p6 <- grid.arrange(p1,p2,p3,p4,p3,p5,nrow = 3)ggsave("scale26.png", p6, width = 6.5, height = 5) 

非线性坐标系

10、分面(facet

Facets divide a plot intosubplots bad on thevalues of one or morediscrete 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 <- subt(mpg, cyl != 5 & drv %in% c("4", "f") & class != "2ater")ba <- ggplot(mpg2, aes(displ, hwy)) +   geom_blank() +   xlab(NULL) +   ylab(NULL)p1 <- ba + facet_wrap(~class, ncol = 3)#三列展示p2 <-ba + facet_wrap(~class,徐鸣涧 ncol = 3, as.table = 课堂教学实录FALSE)p3 <- ba + facet_wrap(~class, nrow = 3)#三行展示p4 <- ba + facet_wrap(~class, nrow = 3, dir = "v")#p5 <- grid.arrange(p1,p2,p3,p4,nrow = 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 <- bap2 <- ba + facet_grid(. ~ cyl)#通过cyl按列绘图p3 <- ba + facet_grid(drv ~ .)#通过drv按行绘图p4 <- ba + facet_grid(drv ~ cyl)#通过drv按行绘图,通过cyl按列绘图p5 <- grid.arrange(p1,p2,p2010福建高考3,p4,nrow = 2)ggsave("scale29.png", p5, width = 6.5, height = 5) 

本文结束,更多好文,欢迎关注:pythonic生物人

Python可视化|Matplotlib39-Matplotlib 1.4W+字教程(珍藏版)

Python可视化|Matplotlib&Seaborn36(完结篇)

python3基础12详解模块和包(库)|构建|使用

Perl基础系列合集

NGS各种组学建库原理(图解)

本文地址:https://blog.csdn.net/qq_21478261/article/details/109086722

本文发布于:2023-04-03 20:33:40,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/a8c0ccc03da12b3e8b0892fd286c3b2d.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:R可视化12.doc

本文 PDF 下载地址:R可视化12.pdf

标签:坐标系   本文   线性   坐标轴
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图