ggplot例子整理.pptx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ggplot例子整理

Using ggplot2 Hadley Wickham 是 RStudio 的首席科学家以及 Rice University 统计系的助理教授。他是著名图形可视化软件包 ggplot2 的开发者,以及其他许多被广泛使用的软件包的作者,代表作品如 plyr、reshape2 等 Layout 概念 例子 Layout 数据和映射 ggplot(data,aes(x=,y=,fill=)) 数据集 映射 Layout 几何对象 :散点图,气泡图,条形图,折线图,箱形图 统计变换 :封箱(bin),identity 位置调整:dodge,fill,identity 坐标系统: xlim,ylim 图层 分面: facet_grid 例子 1散点图起手势 ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() Mtcars数据格式 2shape参数修改图形的形状 ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(shape=21) 3size参数修改图形的大小 ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(size=1.5) ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(size=5) 4 多因素作图 heightweight[, c(sex, ageYear, heightIn)] ggplot(heightweight, aes(x=ageYear, y=heightIn, colour=sex)) + geom_point() ggplot(heightweight, aes(x=ageYear, y=heightIn, shape=sex,color=sex)) + geom_point() 5 scale_shape_manual 设置想要shape ggplot(heightweight, aes(x=ageYear, y=heightIn, shape=sex, colour=sex)) + geom_point() + scale_shape_manual(values=c(1,2)) + scale_colour_brewer(palette=Set1) ggplot(heightweight, aes(x=ageYear, y=heightIn, colour=weightLb)) + geom_point() ggplot(heightweight, aes(x=ageYear, y=heightIn, size=weightLb)) + geom_point() 6scale_fill_gradient设置legend的颜色 ggplot(heightweight, aes(x=weightLb, y=heightIn, fill=ageYear)) + geom_point(shape=21, size=2.5) + scale_fill_gradient(low=black, high=red) 7scale_fill_gradient设置break的大小 ggplot(heightweight, aes(x=weightLb, y=heightIn, fill=ageYear)) + geom_point(shape=21, size=2.5) + scale_fill_gradient(low=black, high=red, breaks=12:17, guide=guide_legend()) 8scale_size_area()使图形比例恰当 ggplot(heightweight, aes(x=ageYear, y=heightIn, size=weightLb, colour=sex)) + geom_point(alpha=.5) + scale_size_area() +scale_colour_brewer(palette=Set1) 9Alpha参数修改透明度 sp - ggplot(diamonds, aes(x=carat, y=price)) sp + geom_point() sp + geom_point(alpha=.1) sp + geom_point(alpha=.01) 10使用bin方法显示高密度散点图 sp + stat_bin2d() 10Bin设置区分度, scale_fill_gradient limit设置上标下标 sp + stat_bin2d(bins=50) + scale_fill_gradien

文档评论(0)

shuwkb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档