79289898

Date: 2024-12-18 03:26:24
Score: 1
Natty:
Report link

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()

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Breeze