Dear fellow R users, I'd like to color individual points in a stripchart. This works well as long as I have only a single value per y axis category:
df <- data.frame(year = seq(2011, 2018), value = seq(10,80, 10)) df$color <- 'black' df[df$value<33,]$color <- 'blue' df[df$value>66,]$color <- 'red' stripchart(df$value ~ df$year, pch=18, col=df$color, method='stack') When I use multiple values per y axis category, all points in a specific y axis category have the same color: set.seed(20210310) years <- sample(x=seq(2011, 2018), size = 365*8, replace = TRUE) values <- sample(x=seq(0,100), size = 365*8, replace = TRUE) df <- data.frame(year = years, value = values) df$color <- 'black' df[df$value<33,]$color <- 'blue' df[df$value>66,]$color <- 'red' stripchart(df$value ~ df$year, pch=18, col=df$color, method='stack') I'd expect to see all points with a value below 33 in blue color, all points with a value above 66 in red color, and the remaining points in black color. I can use a black stripchart plot as basis and plot blue and red points over the black ones, but I do not get the stacking right: stripchart(df$value ~ df$year, pch=18, method='stack') points(df[df$color=='blue',]$value, df[df$color=='blue',]$year-2010, type='p', pch=18, col='blue') points(df[df$color=='red',]$value, df[df$color=='red',]$year-2010, type='p', pch=18, col='red') Am I somehow misusing the stripchart function? Best regards, Robin -- Dr. Robin Haunschild Max Planck Institute for Solid State Research Heisenbergstr. 1 D-70569 Stuttgart (Germany) phone: +49 (0) 711-689-1285 fax: +49 (0) 711-689-1292 email: r.haunsch...@fkf.mpg.de http://www.fkf.mpg.de/ivs Publons: https://publons.com/researcher/2845202/robin-haunschild/ GS: https://scholar.google.de/citations?user=kDfateQAAAAJ&hl=de&oi=ao
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.