2016-08-05 93 views
1

我找到了關於刪除單個圖的右邊框的帖子,但找不到有關刪除facelet右邊框的帖子。 考慮到以下代碼產生的方面,例如是否可以刪除每個方面的右邊框?刪除ggplot2中方面的右邊框

library(reshape2) 
    library(ggplot2) 
    sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill)) + geom_point(shape=1) 
    sp + facet_wrap(~ day, ncol=2) + theme_bw() + 
    theme(strip.text = element_text(size=12,colour="black"), 
    strip.background = element_rect(colour="white", fill="white")) 

enter image description here

回答

3

除非我記錯了,這是prbly你要能夠做到最好:

library(reshape2) 
library(ggplot2) 

sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill)) 
sp <- sp + geom_point(shape=1) 
sp <- sp + geom_hline(yintercept=0) 
sp <- sp + geom_vline(xintercept=0) 
sp <- sp + scale_x_continuous(expand=c(0,0)) 
sp <- sp + scale_y_continuous(expand=c(0,0)) 
sp <- sp + facet_wrap(~day, ncol=2) 
sp <- sp + theme_bw() 
sp <- sp + theme(panel.border=element_blank(), 
       strip.text=element_text(size=12, colour="black"), 
       strip.background=element_rect(colour="white", 
               fill="white")) 
sp 

enter image description here

我prbly嘗試調整刻度大小以確保它們匹配人造軸。

+0

感謝您的回答@hrbrmstr! 但我還有一個問題。 是否可以在刻面軸上保留刻度線? 除了「太陽」面,其他人都在某個軸上缺少刻度線。 「Fri」刻面在x軸上沒有刻度標記,「Thur」刻面在y軸上沒有它們,「Sat」刻面在其任何軸上都沒有刻度線。 我想知道是否有可能保持這些刻面軸上的刻度線。 –