0
我有一些很好的格式數據,我希望在2x2格式上繪圖,每個單獨的繪圖都有自己的X和Y比例。下面是我使用的是現在的代碼:獲取具有不同比例尺的2x2 facet_grid
p <- ggplot(data=temp,aes(x=variable,y=value,group=custno,color=cluster)) +
geom_path(alpha=0.4) +
theme_bw() +
theme(legend.title=element_blank(),axis.text.y=element_text(hjust=0, angle=0),
axis.text.x = element_text(hjust=1, angle=45),plot.title=element_text(size=20)) +
ylab('Revenue') +
xlab('') + ggtitle('') +
scale_color_manual(values=c('#66c2a5','#fc8d62','#8da0cb','#e78ac3')) +
facet_grid(.~cluster,scales='free',space='free')
p
下面是我得到的情節:
我希望有獨立的鱗片一個2x2的網格,所以這一類3
是一點點榮耀,差異更加明顯。
這裏的樣本數據
custno variable value cluster
100 Month1 169.15 3
250 Month1 4012.15 1
303 Month1 2731.08 1
312 Month1 890.40 2
337 Month1 1133.40 3
100 Month2 169.15 3
250 Month2 4012.15 1
303 Month2 2731.08 1
312 Month2 890.40 2
337 Month2 1133.40 3
100 Month3 169.15 3
250 Month3 4012.15 1
303 Month3 2731.08 1
312 Month3 890.40 2
337 Month3 1133.40 3
100 Month4 169.15 3
250 Month4 4012.15 1
303 Month4 2731.08 1
312 Month4 890.40 2
337 Month4 1133.40 3
100 Month5 169.15 3
250 Month5 4012.15 1
303 Month5 2731.08 1
312 Month5 890.40 2
337 Month5 1133.40 3
100 Month6 169.15 3
250 Month6 4012.15 1
303 Month6 2731.08 1
312 Month6 890.40 2
337 Month6 1133.40 3
任何幫助將非常感激。
謝謝。我試過這個,但得到以下錯誤:'layout_base(data,vars,drop = drop)中的錯誤: 至少有一個圖層必須包含所有用於構圖的變量' – Patthebug 2014-12-05 20:13:56
不確定在facet_wrap中應該有一個點嗎? – baptiste 2014-12-05 20:16:21
發佈了一些示例數據 – Patthebug 2014-12-05 20:19:42