医学统计

R语言与医学统计图形-【9】过渡函数qplot

倖福魔咒の 提交于 2020-02-14 17:05:33
ggplot2绘图系统 基础绘图包向ggplot2过渡——qplot 绘图理念的不同: 基础绘图包是先铺好画布,再在这张画布上作图(常规思维); ggplot2打破常规,采用图层叠加的方法。 qplot函数既有plot特点,又体现了ggplot2的特征,是一个过渡函数。 library(ggplot2) data("diamonds") qplot(x=carat, y=price, data=diamonds, geom = 'point', color=color) #geom几何对象:smooth/boxplot/path/line/freqpoly/density/jitter/bar #color映射变量 set.seed(2020) dsmall <- diamonds[sample(nrow(diamonds),1000),] qplot(x=carat, #qplot中x/y不能省 y=price, data=dsmall, geom='point', color=color, shape=cut) #映射形状 qplot(x=color, data=dsmall, geom = 'bar', fill='green', #填充色 color='red') #边框色 #此处green和red都视为了一个变量 qplot(x=color, data=dsmall,