I am making a scatterplot using ggplot2. I have 17 groups that need to be displayed though, and I am trying to find ways of making that many colors distinguishable from each other. How could I put a black outline on every other grouping so that the black outline shows both in the scatterplot and in the legend.
Here is a reproducible example of having too many colors to visualize. I would like 'Group 1', 'Group 11', 'Group 13', etc. to have a black outline around them so that they are distinguishable from their neighbors.
groupings <- paste0("Group", 1:15)
iris$group <- rep(groupings, 10)
iris_plot <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point(aes(Sepal.Length, Sepal.Width, colour = factor(iris$group)))
shrink_legend <- function(NMDS, pointSize, textSize, spaceLegend){
NMDS +
guides(shape = guide_legend(override.aes = list(size = pointSize)),
color = guide_legend(override.aes = list(size = pointSize))) +
theme(legend.title = element_text(size = textSize),
legend.text = element_text(size = textSize),
legend.key.size = unit(spaceLegend, "lines"))
}
shrink_legend(iris_plot, pointSize = 1.2, textSize = 10, spaceLegend = 0.5)
Thank you for your help!
