2

Here is my code:

ggplot() + geom_sf(st_as_sf(seventeen), mapping = aes(fill = NEIGHBOR_T)) +
  geom_sf(st_as_sf(new_sp), mapping = aes(color = SafeRating), size = 3.8) +
  geom_sf(st_as_sf(new_sp), mapping = aes(color = SafeRating), size = 3.8,
          colour = "black", pch = 21) + coord_sf(datum = NA) + theme_void() +
  ggtitle("I feel safe in my neighborhood.") +
  theme(plot.title = element_text(hjust = 0.5, size = 35),
        text = element_text(family = "Optima", size = 25),
        legend.position = "bottom",
        legend.key = element_rect(fill = "black"),
        legend.key.size = unit(1, "cm"),
        legend.title.align = 0.5,
        legend.box = "vertical",
        plot.background = element_rect(fill = "white")) +
  scale_fill_manual(name = "Neighborhood Type: ",
                    values = c("#08B6CE", "#398AD7", "#2F66A9")) +
  scale_color_manual(name = "Rating: ",
                     values = c("red", "dark red", "#675E24", "dark green", "green"),
                     labels = c("Strongly Disagree", "Disagree",
                                "Neutral", "Agree", "Strongly Agree"))

Here is what the visualization currently looks like:

img

I would like the squares associated with the ratings to be filled in just like for the neighborhood types. How is this done?

camille
  • 16,432
  • 18
  • 38
  • 60
  • Have you tried setting `fill` in your `geom_sf`s? – Igor F. Nov 17 '19 at 18:36
  • This has been an [issue](https://github.com/tidyverse/ggplot2/issues/3572) with `geom_sf`. Set `show.legend = "point"` inside `geom_sf` – camille Nov 17 '19 at 19:17
  • There are a few SO posts that cover this, such as [this one](https://stackoverflow.com/q/53273286/5325862) and [this](https://stackoverflow.com/q/49555694/5325862) – camille Nov 17 '19 at 19:21
  • To clarify, I am not trying to add points. I want the squares for ratings to be completely filled in with color, just like they are for neighborhood type. – StatisticallyMagnificent Nov 17 '19 at 19:49

0 Answers0