Change color for one element in a beeswarm plot in R

467 Views Asked by At

Starting from a .csv I'd like to highlight a single point in a beeswarm plot.

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)
1

There are 1 best solutions below

0
Andrew Gustar On BEST ANSWER

You can set the colour of individual points using the pwcol argument. Here is an example...

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)

So you just need to set a suitable vector of colours to fit your data.