One solution I've found so far is to write it into guides
so that the height and width can be adjusted.
ggplot(data = data, aes(x = x, y = y, fill = lyr.1)) +
geom_tile() +
scale_fill_gradientn(
colors = bwr_colors,
na.value = NA,
limits = c(5, 20),
oob = scales::oob_squish,
) +
guides(fill = guide_colbar(
position = 'bottom',
theme = theme(
legend.key.width = unit(4, "cm"),
legend.key.height = unit(0.5, "cm"),
legend.title.position = "top",
legend.title = element_text(hjust = 0.5)
)
))+
theme_bw()