I want to create a map like:
edit: this screenshot is from Claus Wilkes book 
Here is another code to mimick the visual that you show.
ggplot(data=test)
statebins:::geom_rrect(data=test, mapping=aes(xmin=1, xmax=2, ymin=1, ymax=2),
fill = '#d0e1e1',
color=NA, alpha=0.7)
statebins:::geom_rrect(data=test %>%
dplyr::filter(!is.na(value)),
mapping=aes(xmin=1, xmax=2, ymin=1, ymax=2, fill = value),
color=NA, alpha=1)
geom_text(data=test, aes(x = 1.5, y = 1.5, label = state))
# annotate("text", x=1.5, y=1.5, label= state)
facet_geo(~state, grid="ch_cantons_grid2")
scale_fill_gradient(low = "#dccbd7", high = '#564364', name = "Label value")
theme_minimal()
guides(fill = guide_legend(title.position = "top"))
theme(legend.position = c(0.2, 0.95),
legend.direction="horizontal")
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
strip.placement = "bottom",
plot.title = element_text(hjust = 5),
strip.background = element_blank(),
strip.text.x = element_blank(),
line = element_blank())
You can change guides(fill = guide_legend(title.position = "top")) by guides(fill = guide_colorbar(title.position = "top")) to have continuous color scale.


