0
我想2 ggplot barchart
彼此相鄰結合成一個曲線圖:ggplot geom_bar在一個圖形組合
ggplot(data, aes(Year,lossratio1)) + geom_bar(stat="identity", colour="blue", fill="blue")
ggplot(data, aes(Year, lossratio2) + geom_bar(stat="identity", colour="red", fill="red")
注:
- x軸是
year
- Y-軸是
lossratio1
和lossratio2
。
條形圖填充分別跟在lossratio
之後。
請出示一些數據,例如。使用'輸入(頭(數據,10))'。但我認爲已經有一個答案,請參閱這篇文章,例如:http://stackoverflow.com/questions/18158461/grouped-bar-plot-in-ggplot – Jimbou
Year = c(2010,2011,2012,2013,2014 ,2015,2016)lossratio1 = c(0.5,0.6,0.7,0.8,0.9,0.95,1)lossratio2 =(0.6,0.65,0.7,0.75,0.8,0.85,0.9)data = data.frame(Year,lossratio1, lossratio2)當我使用這個圖時:ggplot(data)+ geom_bar(aes(Year,lossratio1),data,stat =「identity」,color =「blue」,fill =「blue)+ geom_bar(aes(Year,lossratio2 ),data,stat =「identity」,color =「red」,fill =「red」),這表示重疊區域是紅色的,我應該在哪裏放置位置=「閃避」? – user6648245