如何使用 2 种条件对点进行着色?

How do I color points using 2 conditions?

我想根据 Depo 是否满足我的 Cutoff 标准,用 Depo 为散点图中的点着色。我尝试通过 Depo 着色并使用 Cutoff 的形状,但这并没有给我想要的视觉效果。仅当 Cutoff = Good/MaybeCutoff = Bad 黑色的所有点时,我才真正想要 Depo 着色的点。

Depth    Pj         T         Depo    Cutoff
100.69    1.095802    0.9986513    Dri    Good
97.04    1.009357    0.9624445    Pro    Good
74.74    1.039274    0.9880176    Tur    Maybe
106.46    1.054291    0.9873374    Pro    Maybe
109.37    1.117034    0.9913281    Dri    Bad
90.29    1.01166        0.9107071    Pro    Bad

我试过了,但它并没有让坏样本脱颖而出

ggplot(MyData, aes(x=Pj, y=T, colour = Depo, shape = Cutoff)) + geom_point()

这样的事情怎么样?

df %>%
    mutate(col = factor(ifelse(
        Cutoff %in% c("Good", "Maybe"),
        as.character(Depo),
        NA))) %>%
    ggplot(aes(x = Pj, y = T, colour = col, shape = Cutoff)) +
    geom_point()


示例数据

df <- read.table(text = "Depth    Pj         T         Depo    Cutoff
100.69    1.095802    0.9986513    Dri    Good
97.04    1.009357    0.9624445    Pro    Good
74.74    1.039274    0.9880176    Tur    Maybe
106.46    1.054291    0.9873374    Pro    Maybe
109.37    1.117034    0.9913281    Dri    Bad
90.29    1.01166        0.9107071    Pro    Bad", header = T)