Bars to be plotted over map

后端 未结 1 695
情话喂你
情话喂你 2020-12-18 14:14

I want to draw barchart over map as on this page: http://docs.oracle.com/cd/E16162_01/web.1112/e16181/dv_map.htm#BEHHAFEJ

1条回答
  •  北海茫月
    2020-12-18 14:31

    You could try using subplots:

    # ...
    plot(getMap())
    df <- merge(x=ddf, y=sPDF@data[sPDF@data$ADMIN, c("ADMIN", "LON", "LAT")], by.x="country", by.y="ADMIN", all.x=TRUE)
    require(TeachingDemos)
    for (i in 1:nrow(df)) 
      subplot(barplot(height=as.numeric(as.character(unlist(df[i, 2:4], use.names=F))), 
                      axes=F, 
                      col=rainbow(3), ylim=range(df[,2:4])),
              x=df[i, 'LON'], y=df[i, 'LAT'], size=c(.3, .3))
    legend("topright", legend=names(df[, 2:4]), fill=rainbow(3))
    

    enter image description here

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