是否有一种方法可以使notification_custom使用非笛卡尔坐标?

时间:2019-05-09 10:26:22

标签: r ggplot2

我正在尝试创建一个地图,在特定位置绘制几个条形图,以显示某些公司在不同城市的分布。

我将条形图作为注释自定义,并在地图上指定要绘制条形图的区域,其作用就像是一种魅力。

但是,我需要在特定的投影中绘制最终地图,但注释自定义似乎仅适用于笛卡尔坐标。有什么办法可以解决这个问题?

 ##Create base map
    map.test <- ggplot(gadm)+
      geom_polygon(aes(long, lat, group=group), fill="lightgrey")+
      coord_fixed()+
      geom_path(color="white", mapping=aes(long, lat, group=group), 
size=0.2, alpha=.25)+
      geom_text(data=locations_georef, aes(x=lon, y=lat,                                          label=paste(locations_georef$Metro,locations_georef$Anzahl,sep=": ")), 
                size=2.5)+
      scale_x_continuous(name=NULL,labels=NULL)+
      scale_y_continuous(name=NULL,labels=NULL)+
      theme(rect = element_blank(),
            line = element_blank())


    ##That is how I create the list of annotation_customs
    bar_annotation_list <- lapply(1:length(locations_georef$metro), function(i) 
      annotation_custom(bar.testplot_list[[i]], 
                        xmin = locations_georef$lon[i] - locations_georef$size[i],
                        xmax = locations_georef$lon[i] + locations_georef$size[i],
                        ymin = locations_georef$lat[i] ,
                        ymax = locations_georef$lat[i] + 1))

    ##plot it on a previously created map of Germany
    map.test+bar_annotation_list

到目前为止很棒,但是如果我尝试做类似的事情不起作用

result_plot + coord_proj("any_projection")

0 个答案:

没有答案
相关问题