0

I wanted to plot points on the state of New York map that I made through

#NY state map

usa <- map_data("usa")
states <- map_data("state")
ny_df <- subset(states, region=="new york")
ny_base <- ggplot(data=ny_df, mapping=aes(x=long, y=lat, group=group))+
  coord_fixed(1.3) + 
  geom_polygon(color="black", fill="gray")
ny_base+theme_nothing()

counties <-map_data("county")
ny_county <- subset(counties, region=="new york")
ny_base + theme_nothing() + 
  geom_polygon(data=ny_county,fill=NA, color="white")+
  geom_polygon(color="black", fill=NA)

The above code gives me this:

enter image description here

However, once I'm trying to add my points through

ny_base + theme_nothing() + 
   geom_polygon(data=ny_county,fill=NA, color="white") + 
   geom_polygon(color="black", fill=NA) + 
   geom_point(data=go, aes(x=Longitude, y=Latitude), color="red", pch=1, size=1, inherit.aes=FALSE)

The above code gives me this:

enter image description here

I lose my NY state map and I only get to keep my points. What seems to be the problem?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
potatopainting
  • 103
  • 1
  • 9
  • 1
    What's stored in the variable `go`? It looks like you have data from all over the world, not just NY. It's possible the state is still being drawn, but since you are drawing points all over the world, it's really zoomed out and the points seem to completely cover the state. – MrFlick Oct 08 '18 at 19:00
  • 1
    If you look at your points, they seem to outline the world map. You need to filter your `go` coordinates to just ones in NY – Mako212 Oct 08 '18 at 20:52
  • 1
    See this answer for an example of how to do it: https://stackoverflow.com/a/33530046/4421870 – Mako212 Oct 08 '18 at 20:54

0 Answers0