plotting pie graphs on map in ggplot

后端 未结 5 1326
情话喂你
情话喂你 2020-11-28 04:12

This may be a wish list thing, not sure (i.e. maybe there would need to be the creation of geom_pie for this to occur). I saw a map today (LINK) with pie graph

5条回答
  •  余生分开走
    2020-11-28 04:53

    A slight variation on the OP's original requirements, but this seems like an appropriate answer/update.

    If you want an interactive Google Map, as of googleway v2.6.0 you can add charts inside info_windows of map layers.

    see ?googleway::google_charts for documentation and examples

    library(googleway)
    
    set_key("GOOGLE_MAP_KEY")
    
    ## create some dummy chart data
    markerCharts <- data.frame(stop_id = rep(tram_stops$stop_id, each = 3))
    markerCharts$variable <- c("yes", "no", "maybe")
    markerCharts$value <- sample(1:10, size = nrow(markerCharts), replace = T)
    
    chartList <- list(
      data = markerCharts
      , type = 'pie'
      , options = list(
        title = "my pie"
        , is3D = TRUE
        , height = 240
        , width = 240
        , colors = c('#440154', '#21908C', '#FDE725')
        )
      )
    
    google_map() %>%
      add_markers(
        data = tram_stops
        , id = "stop_id"
        , info_window = chartList
      )
    

提交回复
热议问题