繁体   English   中英

在ggplot2中删除facet的右边框

[英]Remove right border of facets in 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"))

在此输入图像描述

除非我弄错了,否则这是你能做的最好的事情:

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

在此输入图像描述

我会尝试调整刻度尺寸以确保它们与人造轴匹配。

暂无
暂无

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

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