I'd like to do a scatter plot with 2 categories of the data, one plotted in yellow and one in blue, and them showing up in green where they overlay (or any other combination). I've found that things are a little more difficult even with transparency. The colour of the graph is influenced by whether the last point plotted in a space was blue or yellow.
For example with the following code:
col1 <- rgb(red = .0, green = 0, blue = 0.8, alpha = 0.8)
col2 <- rgb(red = .8, green = 0.8, blue = 0, alpha = 0.8)
circle <- data.frame(x = c(0.2,0),
y = c(0,0),
col = c(col1, col2),
stringsAsFactors = F)
orders <- c(1,2)
plot(x = circle$x[orders], y = circle$y[orders],
col = circle$col[orders], pch = 19, cex = 100, xlab = "", ylab = "")
Depending on how you set the vector orders
(which sets up which way round the two large points are drawn) you get different results:
And if you swap the order in which you plot the two circles round you get:
Either way, I was anticipating mixing the colours to get a green. Is there a way to do this? Thanks!
Edit - the two plots were made using the pdf device. I've also tried running the code through tikzDevice to see if that worked but it didn't.