不幸的是,数据有点太大,我无法分享。
map_save <- data.frame(map('state' , region=c('maine', 'new hampshire', 'vermont', 'massachusetts', 'rhode island', 'connecticut',
'new york', 'pennsylvania','west virginia','delaware', 'new jersey', 'maryland', 'virginia', 'north carolina'),
boundary=T,
ylim=lat.range, xlim=lon.range,myborder=c(0,0),
plot=FALSE)[c('x','y')])
for (ss in stocks){
crabs_sub <- crabs[crabs$SPP==ss & crabs$YEAR>=1982,]
for (yy in years){
crabs_yr <- crabs_sub[crabs_sub$YEAR==yy,]
dat <- data.frame(YEAR=crabs_yr[,'YEAR'],
Longitude=crabs_yr[,'LON'],Latitude=crabs_yr[,'LAT'],
biomass=crabs_yr[,'BIO'])
print(
ggplot(map_save, aes(x=x, y=y)) +
labs(title=paste0(names[which(stocks==ss)],' - ',yy)) +
geom_path() +
coord_map(project = "mercator", xlim=lon.range,ylim=lat.range) +
geom_point(aes(x=Longitude,y=Latitude,size=log(biomass+1)),data=dat[,],alpha=1/2,shape=21,color='black',fill='black') +
scale_size_continuous(name='Log(biomass+1)') +
labs(x = "Longitude", y = "Latitude", size = 20) +
)
}
}