0
使用下面的數據集:在ggplot中使用scale =「free」時,可以調整最小y值嗎?
day <- gl(8,1,48,labels=c("Mon","Tues","Wed","Thurs","Fri","Sat","Sun","Avg"))
day <- factor(day, level=c("Mon","Tues","Wed","Thurs","Fri","Sat","Sun","Avg"))
month<-gl(3,8,48,labels=c("Jan","Mar","Apr"))
month<-factor(month,level=c("Jan","Mar","Apr"))
snow<-gl(2,24,48,labels=c("Y","N"))
snow<-factor(snow,levels=c("Y","N"))
count <- c(.94,.95,.96,.98,.93,.94,.99,.9557143,.82,.84,.83,.86,.91,.89,.93,.8685714,1.07,.99,.86,1.03,.81,.92,.88,.9371429,.94,.95,.96,.98,.93,.94,.99,.9557143,.82,.84,.83,.86,.91,.89,.93,.8685714,1.07,.99,.86,1.03,.81,.92,.88,.9371429)
d <- data.frame(day=day,count=count,month=month,snow=snow)
我喜歡的y標尺在該圖中,但不是吧:
ggplot()+
geom_line(data=d[d$day!="Avg",],aes(x=day, y=count, group=month, colour=month))+
geom_bar(data=d[d$day=="Avg",],aes(x=day, y=count, fill=month),position="dodge", group=month)+
scale_x_discrete(limits=levels(d$day))+
facet_wrap(~snow,ncol=1,scales="free")+
scale_y_continuous(labels = percent_format())
我喜歡的點,而不是規模:
ggplot(data=d[d$day=="Avg",],aes(x=day, y=count, fill=month,group=month,label=month),show_guide=F)+
facet_wrap(~snow,ncol=1,scales="free")+
geom_line(data=d[d$day!="Avg",],aes(x=day, y=count, group=month, colour=month), show_guide=F)+
scale_x_discrete(limits=levels(d$day))+
scale_y_continuous(labels = percent_format())+
geom_point(aes(colour = month),size = 4,position=position_dodge(width=1.2))
- 如何結合上述圖表中所需的品質?
本質上,我問:我怎樣才能將y-min設置爲零時用不同的y-max來繪製點?
注:我打算找到的解決方案將適用於從一個數據框構建的約27個圖。所以我會對這些解決方案進行投票,以避免更改個別圖表。我希望能夠應用於所有包面圖的解決方案。
小問題(可能爲一個單獨的職位): - 我怎樣一個傳奇添加到每個小包裝的圖表? 如何將圖例的標題更改爲「每週平均」?如何 可以改變線/點的形狀/顏色,然後在一個圖例中報告 ?
您的其他問題可能會在他們自己的討論主題中更好,並帶有最低限度的自己的示例。 – baptiste 2013-05-14 18:13:43