2017-05-06 75 views
2

我試圖更改顯示繪圖頂部的x值到繪圖底部的默認設置。顯示馬賽克圖下方的軸標籤

這裏是一個小例子:

Betta <- c(1,12,23,20) 
dim(Betta) <- c(2,2) 
dimnames(Betta) <- list(Temperature = c("28", "25"), Flare = c("Yes", "No")) 
mosaicplot(x = Betta, main = "Title") 

enter image description here

而爲了清楚起見,我試圖移動的溫度值28和25,在圖上的底部,右側上方x軸「溫度」。

感謝幫助!

+0

的例子你有什麼想在WRT改變「X」設置,它不是來自你的quesstion清楚了嗎? – PKumar

+1

sry,我想要的是將值28和25移動到圖形的底部,所以它會在x軸標籤上方(這是本例中的溫度) –

+0

您可以嘗試打包'ggmosaic',但必須使用'data.frame'而不是應急表。 –

回答

0

您可以使用包ggmosaic下面

df <- as.data.frame(as.table(Betta)) # first, transform the contingency table into a data.frame 
library(ggmosaic) 
ggplot(data=df)+ 
    geom_mosaic(aes(weight=Freq,x=product(Temperature), fill=Flare))+ 
    labs(x="Temperature") 

enter image description here

+0

非常感謝您的幫助!這解決了我的問題。 –

+0

很高興收到您的反饋 –