《ggplot例子整理》PPT课件.ppt

《ggplot例子整理》PPT课件.ppt

ID:51089075

大小:1.91 MB

页数:121页

时间:2020-03-18

《ggplot例子整理》PPT课件.ppt_第1页
《ggplot例子整理》PPT课件.ppt_第2页
《ggplot例子整理》PPT课件.ppt_第3页
《ggplot例子整理》PPT课件.ppt_第4页
《ggplot例子整理》PPT课件.ppt_第5页
资源描述:

《《ggplot例子整理》PPT课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Usingggplot2HadleyWickham是RStudio的首席科学家以及RiceUniversity统计系的助理教授。他是著名图形可视化软件包ggplot2的开发者,以及其他许多被广泛使用的软件包的作者,代表作品如plyr、reshape2等Layout概念例子Layout数据和映射ggplot(data,aes(x=,y=,fill=))数据集映射Layout几何对象:散点图,气泡图,条形图,折线图,箱形图统计变换:封箱(bin),identity位置调整:dodge,fill,identity坐标系统:xlim,ylim图层分面:facet_grid例子1散点图起手

2、势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(he

3、ightweight,aes(x=ageYear,y=heightIn,colour=sex))+geom_point()ggplot(heightweight,aes(x=ageYear,y=heightIn,shape=sex,color=sex))+geom_point()5scale_shape_manual设置想要shapeggplot(heightweight,aes(x=ageYear,y=heightIn,shape=sex,colour=sex))+geom_point()+scale_shape_manual(values=c(1,2))+scale_colo

4、ur_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

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

6、=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_gr

7、adientlimit设置上标下标sp+stat_bin2d(bins=50)+scale_fill_gradient(low="lightblue",high="red",limits=c(0,6000))11scale_fill_gradient设置legend的坐标sp+stat_bin2d()+scale_fill_gradient(low="lightblue",high="red",breaks=c(0,250,500,1000,2000,4000,6000),lim

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。