R在伦敦的情节

时间:2016-01-11 21:09:31

标签: r plot rworldmap

我想在伦敦地图上绘制一些数据。

但每当我尝试运行以下代码时:

library("Hmisc")
library("lubridate")
library("maptools")
require("rworldmap")

mtl <- readShapePoly('borough/London_Borough_Excluding_MHW.shp')

data = read.csv("test.csv")
data = data[,c("Accident_Index","Longitude","Latitude","Date")]

data$Date <- as.character(data$Date)
data$Date <- gsub(' ', '', data$Date)
data$Date <- dmy(data$Date, tz='UTC')

start <- (dmy("01/01/2011", tz='UTC'))
days <- start

# pre processed matrix for incidents
# trust me you don't want to calculate
# this from scratch (Takes hours)
load('time_mat.Rdata')

# plot initial world map
plot(getMap())

da <- 1

# where the plots will be outputted
png(paste('plots/',days[da],'.png',sep=''), height=800, width=1200, bg='grey')

# plot london map
plot(mtl,col='darkgrey')
text(51.5072, 0.1275,paste("Collisions in London\n",days[da]),cex=2)

points(data$Longitude,data$Latitude, pch=20, col='white', cex=2)

par(lwd=2.5,cex=1.4)

subplot(
  plot(days[1:da],incident_rate[1:da],
    lwd=1.5,type='l',
    ylab='', xlab='',
    col='red',
    ylim=c(0,max(c(1,max(incident_rate[1:da]))))
  ),  
  size=c(5.5,2), 51.5072, -0.1275, vadj=0,hadj=0
)

dev.off()
  

par中的错误(plt = c(xy $ x,xy $ y),new = TRUE):     为图形参数指定的值无效&#34; plt&#34;

编辑2:重新考虑并减少了代码。

压缩整个代码文件夹,依赖数据以便于部署/测试,最终被压缩~17mb(由于shapefile):

Megafileupload link

0 个答案:

没有答案