Reputation: 2429
How to change the points such that it is filled with color on the inside (according to the factor) but has a white border on the outside? I can't find an example with the standard pch
chart
library(data.table)
A = data.table(x = 1:4, y = 1:4, z = c('A','A','B','B'))
ggplot(A) + geom_point(aes(x = x, y = y, color = z)) + facet_grid(~z) + theme_bw()
Upvotes: 1
Views: 432
Reputation: 124138
The shape you are looking for is shape=21
. Afterwards map your factor on the fill
aes and set the color for the outline as an argument:
Note: I have set the color to black for the reprex as white isn't really visible.
library(ggplot2)
A <- data.frame(x = 1:4, y = 1:4, z = c("A", "A", "B", "B"))
ggplot(A) +
geom_point(aes(x = x, y = y, fill = z), shape = 21, color = "black", size = 5, stroke = 1) +
facet_grid(~z) +
theme_bw()
Upvotes: 2