Reputation: 4501
In R how do I get ggplot to draw an outline around each legend point? The NA legend entry below looks like "nothing", for lack of a border around said point.
miss <- factor(sample(c(NA, 1:5), nrow(mtcars), replace = TRUE))
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(color = miss)) +
scale_color_grey(na.value = "white") +
geom_point(shape = 1, color = "black") +
theme_bw()
Upvotes: 0
Views: 302
Reputation: 39613
Maybe you are looking for this. You can consider as an option using shape=21
and enable fill
option:
library(ggplot2)
#Code
miss <- factor(sample(c(NA, 1:5), nrow(mtcars), replace = TRUE))
ggplot(mtcars, aes(mpg, wt)) +
geom_point(shape=21,aes(fill = miss),color='black') +
scale_fill_grey(na.value = "white") +
theme_bw()
Output:
Upvotes: 3