xbinbzy的个人博客分享 http://blog.sciencenet.cn/u/xbinbzy

博文

基于ggplot2的散点图

已有 5998 次阅读 2018-10-25 16:44 |个人分类:R语言画图|系统分类:科研笔记

 参考资料:

1)https://ggplot2.tidyverse.org/reference/geom_point.html

2)http://www.sthda.com/english/wiki/ggplot2-scatter-plots-quick-start-guide-r-software-and-data-visualization


数据来源:用ggplot2自带的mtcars,格式如下:

tu1.png

画图代码1:

tu2.png

画图代码2: 散点加颜色(渐变),散点加颜色(离散)

tu2.png

tu2.png

画图代码3:散点加形状(必须用离散变量)

tu2.png

画图代码4:散点大小控制

tu2.png

画图代码5:散点透明度控制

tu2.png

画图代码6:添加回归线,同时可通过geom_smooth()中的method参数去控制回归线

tu2.png

画图代码7:点颜色、形状、大小的修改与控制,这个需要geom_point有color、shape等参数,

scale_shape_manual()、scale_color_manual、scale_size_manual等才能进行修改

tu1.png

画图代码8:控制轴须

tu1.png



https://blog.sciencenet.cn/blog-306699-1142763.html

上一篇:Seasonal cycling in the gut microbiome of the Hadza图1的实现
下一篇:多张图合并的策略
收藏 IP: 120.237.96.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-25 13:26

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部