如何通过rpy2在ggplot2中移除geom_histogram的基线?

4 投票
1 回答
1169 浏览
提问于 2025-04-17 16:15

我正在通过 rpy2 使用 ggplot2 绘制直方图,代码如下:

p = ggplot2.ggplot(df) + \
    ggplot2.aes_string(x="x", colour="sample") + \
    ggplot2.facet_grid(Formula("sample ~ .")) + \
    ggplot2.geom_histogram(binwidth=0.3, fill="white")

效果很好,除了 geom_histogramgeom_density 会在直方图底部添加一根“基线”条,我想把它去掉。请问怎么才能去掉这条线呢?下面是我提到的那条线的图片,上面有箭头标注。谢谢。

enter image description here

1 个回答

1

这个是从条形的边缘来的。

只需要去掉 colour = "sample" 这一行就可以了。

撰写回答