Add line legend to geom_sf

前端 未结 1 599
名媛妹妹
名媛妹妹 2020-12-21 04:33

I have a couple spatial shape files with various public transport routes and I would like to make a map using ggplot2 and sf libraries. The issue h

相关标签:
1条回答
  • 2020-12-21 05:18

    We can use the argument show.legend from geom_sf here.

    ggplot() + 
     geom_sf(data= simple.lines.sf, aes(colour = as.factor(id)), show.legend = "line")
    

    Description of show.legend from ?geom_sf

    logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. You can also set this to one of "polygon", "line", and "point" to override the default legend.

    0 讨论(0)
提交回复
热议问题