I have a data frame of two categories of points. One category has many fewer observations, so I want to plot the points after the larger category's points have already been plotted. Here's a small example :
plotData <- data.frame(category = rep(LETTERS[1:2], c(900, 100)),
group = sample(LETTERS[24:26], 1000, replace = TRUE),
x = rnorm(1000),
y = rnorm(1000))
plotA <- plotData[plotData[, 1] == 'A', ]
plotB <- plotData[plotData[, 1] == 'B', ]
library(scales)
groupColours <- hue_pal()(3)
library(ggplot2)
ggplot(aes(x = x, y = y), data = plotA) + geom_point() + geom_point(data = plotB, colour = group, alpha = 0.65) # Error about 'group' not found. Also need to use scale_colour_manual, but only for the smaller category.
How can I make the smaller category's points be coloured according to group using the colour scale which I picked ?