ggplot2学习心得之qplot

来源:互联网 发布:星际争霸人类 知乎 编辑:程序博客网 时间:2024/06/06 16:49
qplot(x,y,)绘制散点图
qplot()#将变量函数作为参数
colour=color #添加颜色渐变
sharp=cut 添加切工
alpha=I(1/10)##表示10次重叠后不透明
alpha=I(1/100)##表示100次重叠后不透明
alpha=I(1/200)##表示200次重叠后不透明
geom=c("point","smooth")##point表示散点图,smooth表示平滑线
geom=c("point","smooth")##point表示散点图,smooth表示平滑线
geom=c("point","smooth"),span=0.2)##平滑线是否平滑
geom=c("point","smooth"),span=1)##平滑线是否平滑
library(mgcv)
method="gam",fomula=y~s(x))##扩展拟合线
method="gam",fomula=y~s(x,bs="cs"))##扩展拟合线,大数据
library(splines)##包含自然样条:y~ns(x,2),第二个参数随意调
geom=c("point","smooth"),method="lm")
geom=c("point","smooth"),method="lm",fomula = y~ns(x,5))

geom="jitter",alpha=I(1/5))##躁动点图
geom="jitter",alpha=I(1/50))##躁动点图
geom="jitter",alpha=I(1/200))##躁动点图

geom="histogram")#直方图
geom="density")#密度曲线图
geom="histogram",fill=color)#直方图带色
geom="density",colour=color)#密度曲线图带色
geom="histogram",binwidth=0.1,xlim=c(0,3))#直方图 binwidth调节宽度

geom="bar")##条形图,分组计数

geom="bar",weight=carat+scale_y_continuous("carat")##条形图,weight=carat加权,每种颜色的价格总质量

qplot(date,uempmed,data=economics,geom="line")## 绘制时间序列

0 0