更改 R 中蜂群图中一个元素的颜色

Change color for one element in a beeswarm plot in R

从 .csv 文件开始,我想突出显示蜂群图中的一个点。

library("beeswarm")

#carico dati
library(readr)
lavororadar <- read_delim("lavororadar.csv", 
                          ";", escape_double = FALSE, trim_ws = TRUE)
View(lavororadar)

# Beeswarm not penalty goal
beeswarm(lavororadar$npgoal, col=?????, pch=19, method="swarm", cex=0.5)

您可以使用 pwcol 参数设置单个点的颜色。这是一个例子...

beeswarm(rnorm(200),                #some random data
         pwcol = c(1, rep(2, 199)), #first element is colour 1, rest are colour 2
         pch=19, 
         method="swarm", 
         cex=0.5)

所以您只需要设置一个合适的颜色向量来适合您的数据。