| gizmo_barcap | R Documentation | 
This guide displays a colour bar with optional caps at either ends of the bar.
gizmo_barcap(
  key = "sequence",
  shape = "triangle",
  size = NULL,
  show = NA,
  alpha = NA,
  oob = "keep",
  theme = NULL,
  position = waiver(),
  direction = NULL
)
| key | A sequence key specification. Defaults to
 | 
| shape | A cap specification by providing one of the following: 
 | 
| size | A  | 
| show | A  | 
| alpha | A  | 
| oob | An out-of-bounds handling function that affects the cap colour. Can be one of the following: 
 | 
| theme | A  | 
| position | A  | 
| direction | A  | 
A <GizmoBarcap> object.
Other gizmos: 
gizmo_density(),
gizmo_grob(),
gizmo_histogram(),
gizmo_stepcap()
# A standard plot
p <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
  geom_point()
# Just a bar
p + scale_colour_viridis_c(guide = gizmo_barcap())
# Caps show up when there is data outside the limits
p + scale_colour_viridis_c(
  limits = c(10, 30),
  guide  = gizmo_barcap()
)
# The scale's out-of-bounds handler determines cap colour
p + scale_colour_viridis_c(
  limits = c(10, 30), oob = scales::oob_squish,
  guide = gizmo_barcap()
)
# Customising display of the guide
p +
  scale_colour_viridis_c(
    oob = scales::oob_squish,
    guide = gizmo_barcap(
      shape = "arch", show = c(FALSE, TRUE),
      size = unit(2, "cm"),
      theme = theme(legend.key.height = unit(4, "cm"))
    )
  ) +
  theme(
    legend.frame = element_rect(colour = "black"),
    legend.key.width = unit(0.5, "cm")
  )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.