Hi,
I am trying to create a grid of maps, by month, using the facet_wrap function, as in the following code. This code was working previously. I am not able to figure out what's wrong here, but I keep getting the following error. What am I doing wrong? The data is attached. Thank you!!
Ruben Behnke
Error: length(width) == 1 || length(width) == n is not TRUE In addition: Warning messages: 1: `axis.ticks.margin` is deprecated. Please set `margin` property of `axis.text` instead 2: `panel.margin` is deprecated. Please use `panel.spacing` property instead
library(raster)
library(ggplot2)
library(openair)
library(maps)
library(gridExtra)
canada <- getData("GADM",country="CAN",level=1)
provinces
<- c("British Columbia",
"Alberta","Saskatchewan","Manitoba","Ontario",canada$NAME_1[13],"New
Brunswick")
ca.provinces <- canada[canada$NAME_1 %in% provinces,]
cadf
<- fortify(ca.provinces)
theme_clean <- function(base_size=12){
require(grid)
theme_grey(base_size) %+replace%
theme(
axis.title = element_blank(),
axis.text = element_blank(),
panel.background = element_blank(),
panel.grid =
element_blank(),
axis.ticks.length = unit(0,'cm'),
axis.ticks.margin = unit(0,'cm'),
panel.margin =
unit(0,'lines'),
plot.margin = unit(c(0,0,0,0),'lines'),
complete=TRUE)}
Monthly_TdBias <-
read.csv('K:\\Paper1\\New_Bias_Data\\TdHourly_ID_Monthly_ALL_MB_SHORT.csv')
Monthly_TdBias$ID
<- as.character(Monthly_TdBias$ID); Monthly_TdBias$Month <-
as.factor(Monthly_TdBias$Month)
png("K:\\Paper1\\Graphics_Diurnal_Paper\\NEW_Hourly_Biases\\Monthly_MB_MAXVPD.png",width=7500,height=7500,res=650)
states_map
<- map_data('state')
ggplot(data=Monthly_TdBias) +
geom_polygon(data=states_map,aes(x=long,y=lat,group=group),colour='black',fill='white')
+
geom_polygon(data=cadf,aes(x=long,y=lat,group=group),colour='black',fill='white')
+
geom_point(data=Monthly_TdBias, aes(x=Lon, y=Lat, group=NULL,
color=Max_Bias),size=0.8, pch=19) + coord_map(xlim =
c(-130.8,-66),ylim=c(24,53)) +
scale_color_gradient2(limits =
c(-10,10),low='blue',mid='lightgrey',high='red',midpoint=0) + theme_clean() +
facet_wrap(~Month,ncol=3) +
theme(panel.spacing = unit(c(0.2, 0.2, 0.2,
0.2), "cm")) +
theme(strip.text.x = element_text(size = 11, colour =
"black", face='bold')) +
theme(legend.key.height = unit(4, "cm")) +
ggtitle('Mean Daily Bias in Max VPD when assuming Constant Td (Pa)') +
theme(plot.title = element_text(size = 11, face = "bold")) +
theme(legend.title = element_blank()) +
theme(legend.text=element_text(size=11,face='bold'))
dev.off()