与R语言中的plot函数有点类似,qplot()函数前两个参数也是x,y,代表图中的x,y坐标。还可以用data参数来指定数据,作用类似于attach()
library(ggplot2)
qplot(carat,price,data=diamonds)
qplot函数同时也支持将变量的函数作为参数,所以也可以作出log(price)和log(carat)的函数
qplot(log(carat),log(price),data=diamonds)
这种处理过后,图形看起来近似于线性了
函数的参数也可以是已有变量的组合,比如表示体积(x*y*z)
qplot(carat,x*y*z,data=diamonds)