如何在分组数据时为 stat_ellipse 使用固定颜色?

How to use a fixed color for the stat_ellipse while having grouped data?

我只想为绘制的椭圆设置一种颜色,但是当我为每个椭圆提供一种颜色 (stat_ellipse(color="black")) 或一种单独的颜色时,stat_ellipse 在 [=14 之外=] (stat_ellipse(color=ellipses_colors)),我只得到一个椭圆,而不是每个网格面板的每组椭圆。

d <- data.frame(

    value1 = value_in_dimension_1,
    value2 = value_in_dimension_2,
    feature1 = dimension_1,
    feature2 = dimension_2,
    type = cluster_of_point
)


ggplot(d, aes(value1, value2, color=type)) +
    geom_point() +
    stat_ellipse() +
    facet_grid(feature1 ~ feature2)

使用stat_ellipse()时的结果:

结果,当使用 stat_ellipse(color=ellipses_colors)stat_ellipse(color="black") 时:

使用 group 美学并将其设置为类型:

ggplot(d, aes(value1, value2, color=type)) +
    geom_point() +
    stat_ellipse(aes(group = type), colour = "black") +
    facet_grid(feature1 ~ feature2)