geom_polygon_interactive带孔

时间:2019-05-31 09:49:54

标签: r ggplot2 maps ggiraph

我想用ggplot2ggiraph库为我的闪亮应用程序工具创建一个交互式地图。但是我有一个大问题-我的积木上没有孔。

我尝试了ggpolypath。一切都很好,但我确实需要交互式地图

我的代码:

library(ggplot2)
library(ggiraph)

okrug <- read.csv("https://raw.githubusercontent.com/savchukidze/data/master/Dnipro.csv")

extra_css_bar <- "background-color:#333333;font-family:Ubuntu;font-style:bold;color:white;padding:5pt;"
data_css_bar <- "fill:orange;"

#create map
map2 <- ggplot()+
   geom_polygon_interactive(data = okrug, aes(long, lat, fill = smd, 
                                              data_id = smd, group = group), alpha = 0.9,
                            color = "black", size = 0.2)+

   scale_fill_viridis_c("", option = "D", direction = -1, begin = 0 , end = 1, na.value = "#d9d9d9")+
   coord_map(xlim = range(okrug$long), ylim = range(okrug$lat),
   orientation = c(95, 0, 0))+

   theme_minimal(base_family = "Roboto Black")+
   theme(text = element_text(color = "#3A3F4A"),
         panel.grid.major = element_blank(),
         axis.title = element_blank(),
         axis.text = element_blank(),
         legend.position = "bottom",
         legend.text = element_text(family = "Ubuntu Light", color = 'black', hjust = 0.5),
         plot.title = element_text(margin = margin(t = 10, b = 20), color = "#14272d", family ="Ubuntu", face = "bold", hjust = 0.5)

   )
ggiraph(code = print(map2),
        tooltip_extra_css = extra_css_bar, 
        hover_css = data_css_bar,
        tooltip_offy = 10,
        selection_type = "none")

有什么想法吗?)

0 个答案:

没有答案