我有不對齊以下兩部分積:對齊側由端相關曲線與GGPLOT2
Side-by-side plots not aligned
這些圖是通過以下代碼製作:
require(ggplot2)
require(gridExtra)
set.seed(0)
data <- data.frame(x=rpois(30,5),y=rpois(30,11),z=rpois(300,25))
left.plot <- ggplot(data,aes(x,y))
+ geom_bin2d(binwidth=1)
margin.data <- as.data.frame(margin.table(table(data),1))
right.plot <- ggplot(margin.data, aes(x=x,y=Freq))
+ geom_bar(stat="identity")+coord_flip()
grid.arrange(left.plot, right.plot, ncol=2)
如何將左側圖中的行與右側圖中的條對齊?
我不明白,爲什麼在右圖您的解決方案中有4級或更小,而在左邊有3條只有在標記低於4 –
它看起來像我們的隨機數據不同;嘗試對您的機器進行調整,並確認您的左右數字對齊。讓我知道如果他們不。 – Nancy
不,他們不對齊。在你的身影中看到它。左邊的繪圖在右邊的繪圖中沒有數值爲3的數據。看到我上面的答案。 –