R geom_subplot2d:无法在ggplot2中的地图上绘制条形图
我想在的地图上绘制条形图,我正在执行以下操作:R geom_subplot2d:无法在ggplot2中的地图上绘制条形图,r,plot,ggplot2,bar-chart,R,Plot,Ggplot2,Bar Chart,我想在的地图上绘制条形图,我正在执行以下操作: 获取底图-德国地图。(空间多边形文件) 用geom_多边形绘制它 加载所需数据(如下) 计算应绘制钢筋位置的平均值 连接数据 使用geom_subplot2d绘制它 当我运行代码时,一切正常,没有错误或警告。然后它就挂在最后,没有显示任何结果。知道为什么吗?非常感谢你的帮助 options(warn=1) library(XLConnect) library(sp) library(rgdal) library(ggplot2) library(p
geom_多边形
绘制它geom_subplot2d
绘制它options(warn=1)
library(XLConnect)
library(sp)
library(rgdal)
library(ggplot2)
library(plyr)
library(RColorBrewer)
library(DataCombine)
library(rgeos)
library(maptools)
library(mapproj)
###get map###
bundesl<-readOGR("data/new_shape/vg2500_bld.shp", "vg2500_bld")
bundesl$GEN<- as.character(bundesl$GEN)
###draw map- Base plot###
p <- ggplot() + geom_polygon(data=bundesl,aes(x=long, y=lat,group=group), col = "blue4", fill = "lightgray") + theme_minimal()+ coord_map()
p
##load data##
egg <- read.table(text="RS Tariff
01 -5.25
02 7.16
03 6.65
04 3.10
05 3.69
06 2.49
07 1.89
08 3.93
09 -5.84
10 -2.61
11 -0.21
12 2.35
13 -5.94
14 -7.54
15 -3.27
16 -8.75", header=TRUE, colClasses=c("character", "numeric"))
colnames(eeg)<-c("RS", "Tariff")
bundesl<- fortify(bundesl)
# Calculate the mean longitude and latitude per region (places where subplots are plotted),
cntr <- ddply(bundesl,.(id),summarize,long=mean(long),lat=mean(lat))
# #### Shape Daten und EEG Daten join ####
bundesl<-merge(bundesl, eeg)
simdatmyplot <- p+geom_subplot2d(aes(long, lat, subplot = geom_bar(aes(x = RS, y = Tariff, fill = Tariff, width=1), stat = "identity", position = "identity")), ref = NULL, data = bundesl)
simdatmyplot
选项(警告=1)
库(XLConnect)
图书馆(sp)
图书馆(rgdal)
图书馆(GG2)
图书馆(plyr)
图书馆(RColorBrewer)
库(数据合并)
图书馆(rgeos)
图书馆(地图工具)
图书馆(mapproj)
###获取地图###
德国联邦