Rstudio绘图之散点、折线、条形、直方、箱线、函数图

#散点图

head(mtcars)

 plot(mtcars$wt,mtcars$mpg)#基础绘图系统得到的散点图

 #ggplot中qplot()函数得到的散点图得同样图

 install.packages("ggplot2")

 #若两参数向量在同一数据框内

qplot(wt,mpg,data=mtcars)

#等价于

ggplot(mtcars,aes(x=wt,y=mpg))+geom_point()

#折线图(type="l"为线性)

head(pressure)

plot(pressure$temperature,pressure$pressure,type="l")#绘出第一条折线

#向图形中添加数据点或多条折线

points(pressure$temperature,pressure$pressure)#添加数据点

lines(pressure$temperature,pressure$pressure/2,col="red")#添加更多折线

points(pressure$temperature,pressure$pressure/2,col="red")

#ggplot2中qplot()函数绘制折线图

qplot(pressure$temperature,pressure$pressure,geom="line")

#等价于

qplot(temperature,pressure,data=pressure,geom="line")

#等价于

ggplot(pressure,aes(x=temperature,y=pressure))+geom_line()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值