Hi all,
I'm working with the figures and have questions. The data and code are provided below. In the resulting figure, how to remove the title ('Jan', 'Feb', 'Mar', etc) for each sub-panel but keep their orders? Because the titles take too much space and are not very clear, thus I want to edit it stand-alone. Second, how to use fewer bins for the color bar and throughout the sub-panels? For example, 0.00-0.50 uses one color, 0.50-1.00 uses a second color, and values >1.00 uses a third color. This will make the values in the panels and colors easier to recognize. Thanks for your help.
library(tidyverse)
library(ggplot2)
df1 = data.frame( lon= c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat = c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P = c(0.1, 0.1, 0.3, 0.7, 0.6, 0.4, 0.02, NA, NA, NA, NA) )
df2 = data.frame( lon= c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat = c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0.1, 0.5, 1.1, 0.9, 0.5, 0.1, NA, NA, NA, NA) )
df3= data.frame( lon= c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat = c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0.3, 0.3, 0.5, 0.8, 0.9, 0.6, 0.4, NA, NA, NA, NA))
df4= data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0, 0.1, 0.4, 0.6, 0.3, NA, NA, NA, NA))
df5= data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0, 0, 0, 0.7, 1.1, NA, NA, NA, NA))
df6 = data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0.1, 0, 0, 0, 1.3, NA, NA, NA, NA))
df7= data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0.5, 0.5, 0, 0, 1, NA, NA, NA, NA))
df8 = data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0.6, 0.4, 0.2, 0, 0, 0, NA, NA, NA, NA))
df9= data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0.5, 0.5, 0, 0, 0, NA, NA, NA, NA))
df10 = data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0, 0, 0, 0, 0, NA, NA, NA, NA))
df11 = data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0.5, 1.1, 0, 0, 0, NA, NA, NA, NA))
df12= data.frame( lon =c(59.75, 60.25, 60.75, 61.25, 61.75, 62.25 ,62.75, 63.25, 44.25, 44.75, 45.25),
lat= c(26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.25, 26.75, 26.75, 26.75),
P= c(0, 0, 0.5, 0.7, 0.1, 0.1, 0, NA, NA, NA, NA))
data <- bind_rows(df1, df2, df3, df4, df5, df6, df7, df8, df9, df10, df11, df12, .id = "Month") %>%
mutate(Month = lubridate::month(as.numeric(Month), label = TRUE))
ggplot(data, aes(lon, lat, fill = P)) +
geom_tile() + theme_classic() +
scale_fill_distiller('P (mm)', palette = 'Spectral') +
borders('world',xlim = range(df1$lon),
ylim = range(df1$lat),colour = 'black') +
facet_wrap(. ~ Month) +
xlab('Longitude') + ylab('Latitude') +
theme(legend.position = "bottom",legend.text = element_text(angle = 45),
strip.text.x = element_text(size = 8, margin = margin(0, 0, 0, 0, "cm"))) +
guides(fill = guide_colorbar(barwidth = 20, barheight = 0.5))