【问题标题】:How to set geom_point fill for ggplot in rpy2 from Python?如何在 Python 的 rpy2 中为 ggplot 设置 geom_point 填充?
【发布时间】:2013-05-28 14:23:15
【问题描述】:

我正在使用 rpy2 用 ggplot 制作以下简单的情节:

from rpy2.robjects.lib import ggplot2
from rpy2.robjects import r, Formula
# R iris dataset
iris = r('iris')
p = ggplot2.ggplot(iris) + \
    ggplot2.geom_point(ggplot2.aes_string(x="Sepal.Length", y="Sepal.Width", colour="Sepal.Width"), fill="white") + \
    ggplot2.facet_wrap(Formula('~ Species'), ncol=2, nrow = 2) 
p.plot()

除了fill="white" 部分之外,它都可以工作。我希望所有点的填充为白色,而颜色(即点边框颜色)由Sepal.Width 设置。如何才能做到这一点?谢谢。

【问题讨论】:

  • 我认为解决这个问题的唯一方法是使用shape=1 并放弃fill=,我相信这会产生相同的效果吗?

标签: python ggplot2 rpy2


【解决方案1】:

有一个晦涩的技巧:它需要设置pch

看到这个答案: Place a border around points

【讨论】:

    猜你喜欢
    • 2021-09-30
    • 2013-04-04
    • 2013-08-16
    • 2018-07-09
    • 1970-01-01
    • 2016-01-15
    • 2019-01-07
    相关资源
    最近更新 更多