首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >ggplot2-点图

ggplot2-点图

作者头像
生信补给站
发布2020-08-06 10:34:38
发布2020-08-06 10:34:38
4880
举报
文章被收录于专栏:生信补给站生信补给站

p <- ggplot(mtcars, aes(wt, mpg))

p + geom_point()

# Add aesthetic mappings

p + geom_point(aes(colour = qsec))

p + geom_point(aes(alpha = qsec))

p + geom_point(aes(colour = factor(cyl)))

p + geom_point(aes(shape = factor(cyl)))

p + geom_point(aes(size = qsec))

# Change scales

p + geom_point(aes(colour = cyl)) + scale_colour_gradient(low = "blue")

p + geom_point(aes(size = qsec)) + scale_area()

p + geom_point(aes(shape = factor(cyl))) + scale_shape(solid = FALSE)

# Set aesthetics to fixed value

p + geom_point(colour = "red", size = 3)

qplot(wt, mpg, data = mtcars, colour = I("red"), size = I(3))

# You can create interesting shapes by layering multiple points of

# different sizes

p <- ggplot(mtcars, aes(mpg, wt))

p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour = cyl))

p + aes(shape = factor(cyl)) +

geom_point(aes(colour = factor(cyl)), size = 4) +

geom_point(colour="grey90", size = 1.5)

p + geom_point(colour="black", size = 4.5) +

geom_point(colour="pink", size = 4) +

geom_point(aes(shape = factor(cyl)))

# These extra layers don't usually appear in the legend, but we can

# force their inclusion

p + geom_point(colour="black", size = 4.5, show_guide = TRUE) +

geom_point(colour="pink", size = 4, show_guide = TRUE) +

geom_point(aes(shape = factor(cyl)))

参考书籍:021-ggplot2-geoms.pdf

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2016-06-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信补给站 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档