0

I created a ggplot2 map, but I'm having trouble putting the geom_points, where they appear within each region coloring, but they should appear separating indicating "city" and "station".

I also need to know how to leave it separate similar to the image below, where I can later join it with other maps, as if it were a single legend of multiple maps.

exemple what I am trying to do

The code of what i did

ggplot() +
geom_sf(data = pernambuco_shapefile, aes(fill = NM_MESO), color = "black") +
scale_fill_manual(values = c("lightblue", "lightgreen", "mediumorchid", "tomato1", "orange2"),                      labels = c("Agreste Pernambucano", "Mata Pernambucana", "Metropolitana do Recife","São Francisco Pernambucano", "Sertão Pernambucano")) +  
coord_sf(crs = st_crs(4326)) +  
labs(title = "Divisões de Pernambuco", fill = "Mesoregiões de Pernambuco") +
labs(fill = bquote(bold("Mesoregiões de Pernambuco"))) +
theme(legend.title = element_text(face = "bold")) +
theme_minimal() +
annotation_scale(location = "br") +
annotation_north_arrow(which_north = "grid") +
geom_point(data = coord_cidades, aes(x = Longitude, y = Latitude), color = "black", size = 3, shape = 19, shape=Legenda) +
geom_text(data = coord_cidades, aes(x = Longitude, y = Latitude, label = cidade), color = "black", size = 4, nudge_x = c(0.4, 0.25, 0.25, 0, 0.4), nudge_y = c(0, 0, -0.05, 0.12, 0), show.legend = TRUE) +
geom_point(data = coord_estacoes, aes(x = Longitude, y = Latitude ), shape = 8, color = "red", size = 3, show.legend = TRUE) +
xlim(-41.5, -34) +   ylim(-9.5, -7)
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Aug 04 '23 at 19:58
  • If you want a legend for the points you have to map on aesthetics, i.e. move `color=` inside `aes()` and set your desired colors via `scale_color_manual`. – stefan Aug 05 '23 at 06:48

0 Answers0