Reputation: 747
I want to control the transparency of manually specified colors using a column 'x' with values 1 to 10. I can do so by adding 'alpha = x' but in that case I see dark color dots in my scatter plot. Can anybody help?
Here is my code:
plot1 <- qplot(data=srna[srna$norm_sum > 0 & srna$len > 18 & srna$len < 25, ], x=position,y=norm_sum,colour= len)
plot1 + geom_point(size=4) +
theme_bw()+
# scale_alpha_continuous(range = c(0.1, 0.8))+
scale_colour_manual(values = c("19" = "pink","20" = "blue","21" = "green", "22" = "yellow","23" = "violet", "24" = "red"))+
theme(panel.grid.minor.x = element_line(colour='grey94'),panel.grid.minor.y = element_line(colour='grey94'),
panel.grid.major.x = element_line(colour='lightgrey'),panel.grid.major.y = element_line(colour='lightgrey'))
Upvotes: 3
Views: 21591
Reputation: 7928
Tried to reproduce your question (code below) using the default data from the ggplot2 manual and I got this result. Maybe you can point out what the problems are here?
# install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(size=4, alpha = 0.5, aes(colour = factor(cyl))) +
theme_bw() +
scale_colour_manual(values = c("4" = "pink","6" = "blue", "8" = "green")) +
theme(panel.grid.minor.x = element_line(colour='grey94'),
panel.grid.minor.y = element_line(colour='grey94'),
panel.grid.major.x = element_line(colour='lightgrey'),
panel.grid.major.y = element_line(colour='lightgrey'))
Upvotes: 7