You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
https://siyangming.github.io/blogs/qplot_intro/
qplot是quick plot的缩写,与R系统的基本绘图函数plot类似。
查看qplot的帮助文档
?qplot
diamonds数据集
diamonds是ggplot2中的内置数据集,内含54000颗钻石的价格和质量的信息。钻石质量的四个“C”:克拉重量(carat)、切工(cut)、颜色(color)和净度(clarity),五个物理指标:深度(depth)、钻面宽度(table)、x、y和z。
由于diamonds数据集没有经过很好的预处理,从该数据集中随机提取100个样本。
让样本可重复
qplot绘制散点图
qplot(carat, price, data = diamonds)
**
qplot(log(carat), log(price), data = diamonds)
**
qplot(carat, x * y * z, data = diamonds)
qplot可以自动识别分配不同组别的颜色
qplot(carat, price, data = dsmall, colour = color)
qplot(carat, price, data = dsmall, shape = cut)
调节图片的透明度
qplot(carat, price, data = diamonds, alpha = I(1/10))
**
qplot(carat, price, data = diamonds, alpha = I(1/100))
**
qplot(carat, price, data = diamonds, alpha = I(1/200))
qplot的参数geom可以设置绘制图形的种类
geom = “point” 散点图
geom = “smooth” 平滑曲线,展示标准误差
geom = “boxplot” 箱线图
geom = “path”和geom = “line”可以在数据点之间连线
一维的变量分布
geom = “histogram” 直方图
geom = “freqpoly” 频率多边图
geom = “density” 密度曲线
离散变量
geom = “bar”
添加平滑曲线
使用dsmall数据集绘图
qplot(carat, price, data = dsmall, geom = c(“point”, “smooth”))
使用diamonds数据集绘图
qplot(carat, price, data = diamonds, geom = c(“point”, “smooth”))
如果不希望显示标准误,设置se = FALSE
qplot(carat, price, data = diamonds, geom = c(“point”, “smooth”), se = FALSE)
当geom =
The text was updated successfully, but these errors were encountered: