2012-10-26 67 views
1

我用plotmatrix找到相關的數據幀:GGPLOT2 plotmatrix提供免費秤

# Reduce dataset to 1000 to make things run faster 
d <- diamonds[sample(nrow(diamonds), 1000),] 
plotmatrix(d[,-c(2:4)]) + geom_smooth(color="steelblue", method="lm") 

這工作得很好,只要在不同的列是相同的規模。如果它們不是,那麼小規模的列將變得毫無用處。正如你可以看到,如果你運行上面的例子,價格是最大的,所以它殺死所有其他列。

在網格中解決這個問題,我通常會問ggplot獨立繪製每個規模使用:

scales="free_x" 

但是,我怎麼能傳遞到plotmatrix,或使plotmatrix規模獨立不知何故?基於

enter image description here

+1

注意'plotmatrix'仍然把自己描述爲 「實驗」?嘗試在** GGally **包中切換到'ggpairs'。它的設計/默認值是相當不同的,但我相信它會默認爲您處理自由比例。 – joran

+0

ggpairs看起來不錯。它絕對解決了規模問題。然而,與其他元素結合起來並不容易,例如, geom_smooth。 – oneself

+1

我同意這種情節還沒有(還)真正的好選擇。但是,你嘗試過'ggpairs(d [, - c(2:4)], \t \t lower = list(continuous =「smooth」)) – joran

回答

0

從上述joran的意見,使用從GGally包ggpairs:

# Reduce dataset to 1000 to make things run faster 
d <- diamonds[sample(nrow(diamonds), 1000),] 
ggpairs(d[,-c(2:4)], lower=list(continuous = "smooth"))