ggplot(tg,aes(x=dose,y=length,color=supp))+geom_line(linetype="dashed")+geom_point(shape=22,size=3,fill="white")+scale_color_brewer(palette="Set1")
sunspotyear<-data.frame( Year =as.numeric(time(sunspot.year)), sunspots=as.numeric(sunspot.year) ) ggplot(sunspotyear,aes(x=Year,y=sunspots))+geom_area()
将数据集转化为数据框
ggplot(sunspotyear,aes(x=Year,y=sunspots))+geom_area(colour="black",fill="blue",alpha=0.2)#alpha=0.2将透明度调成80%
ggplot(uspopage,aes(x=Year,y=Thousands,fill=AgeGroup))+geom_area()
ggplot(uspopage,aes(x=Year,y=Thousands,fill=AgeGroup))+geom_area(colour="black",size=0.2,alpha=0.4)+scale_fill_brewer(palette="Blues",breaks=rev(levels(uspopage$AgeGroup)))#breaks函数可反转堆积顺序,colour函数和size函数增加了细线