I am trying to plot a scatter plot with 22 variables, so they all need to have different markers. I thought of repeating some shapes and colors from RColorBrew, and everything works fine, except for the legend that does not update with the colors I selected (please see image below). I also attached a working example below. What could I possibly be doing wrong?
#!/usr/bin/env Rscript
library(ggplot2)
library(ggpubr)
library(RColorBrewer)
theme_set(
theme_pubr()
)
data <- data.frame(
x = c(1:22),
y = as.factor(c(1:22))
)
shapes <- rep(15:18, 6)
colors <- rep(brewer.pal(n = 11, name = "Paired"), 2)
plot <- ggplot(data, aes(x=x, y=y, group=y, size=9, color=colors)) +
geom_point(aes(shape=y)) +
scale_shape_manual(values=shapes) +
scale_size(guide="none") +
guides(fill="none", color="none")
plot <- plot + theme(panel.grid.major=element_line(colour="gray", size=0.2),
panel.grid.minor=element_line(colour="gray", size=0.2))
print(plot)

