简体   繁体   English

在ggplot2中删除facet的右边框

[英]Remove right border of facets in ggplot2

I found posts about removing the right border of a single plot, but could not find posts about removing the right border of facets. 我找到了关于删除单个地块的右边界的帖子,但找不到关于删除正面边界的帖子。 Considering the facets produced by the following codes for example, is it possible to remove the right border of each facet? 例如,考虑以下代码产生的方面,是否可以删除每个方面的右边界?

    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"))

在此输入图像描述

Unless I'm mistaken, this is prbly the best you're going to be able to do: 除非我弄错了,否则这是你能做的最好的事情:

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

在此输入图像描述

I'd prbly try to tweak the tick size to ensure they match the faux axes. 我会尝试调整刻度尺寸以确保它们与人造轴匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM