Reputation: 757
My data is below
library(ggplot2)
X <- c(1,2,3,4,5,6,7,8,9,10)
Y <- c(1,2,3,4,5,6,7,8,9,10)
color <- c("red","blue","yellow","red","blue","yellow","red","blue","yellow","red")
data <- as.data.frame(cbind(as.numeric(X),as.numeric(Y),color))
ggplot(data, aes(x=V1, y=V2, color=color)) + geom_point() + scale_color_manual(values = c("#0072B2","#D55E00", "yellow"))
I would like to draw a scatter plot by ggplot2. I would like to see the dots whose color are red are much smaller than the other dots whose color are not red. How can I do it?
Upvotes: 1
Views: 451
Reputation: 4524
use the same aes for size and specifiy size manually as you did for color
ggplot(data, aes(x=V1, y=V2, color=color, size = color)) +
geom_point() +
scale_color_manual(values = c("#0072B2","#D55E00", "yellow"))+
scale_size_manual(values = c(4, 1, 4))
Upvotes: 2