Small ggplot2 patches placed at ggmap coordinates

I would like to use ggmap first to plot a specific area with longitude and latitude as axes.

Then I would like to place small ggplot2 graphs in specific places, given their longitude and latitude. These can be barriers with a minimum theme.

My database may have columns:

1. town
2. longitude
3. latitude
4. through 6. value A, B, C

I generate a graph (pseudo code)

p <- ggmap(coordinates) 

and i have my minimal ggplot2 design

q<-ggplot2()+geom_bar(....)+ ... x-axis null y axis null minimal template

How to combine two projects with ggmap with small minimal ggplot graphs superimposed on specific map coordinates?

+2
source share
1 answer

. - lat/long.

R:: ggplot2:: geom_points: ?

. , . , , , .


:

enter image description here

, .

p <- ggmap(Poland) + coord_quickmap(xlim = c(13, 25), ylim = c(48.8, 55.5), expand = F)

.

df.grobs <- df %>% 
  do(subplots = ggplot(., aes(1, value, fill = component)) + 
       geom_col(position = position_dodge(width = 1), 
                alpha = 0.75, colour = "white") +
       geom_text(aes(label = round(value, 1), group = component), 
                 position = position_dodge(width = 1),
                 size = 3) +
       theme_void()+ guides(fill = F)) %>% 
  mutate(subgrobs = list(annotation_custom(ggplotGrob(subplots), 
                                           x = lon-0.5, y = lat-0.5, 
                                           xmax = lon+0.5, ymax = lat+0.5))) 

dodge geom_col, geom_text. round(value, 1) x y subplots = ggplot(...). , , 0,35 0,5 .

df.grobs %>%
  {p + 
    .$subgrobs + 
    geom_text(data=df, aes(label = name), vjust = 3.5, nudge_x = 0.065, size=2) + 
    geom_col(data = df,
             aes(Inf, Inf, fill = component), 
             colour = "white")}

, , "" geom_col. 0,0, , x y. Inf, Inf, , , , .

+2

Source: https://habr.com/ru/post/1690414/


All Articles