Skip to content

Cannot update the width geom default for geom_bar/geom_col and geom_errorbar #6224

Closed
@davidhodge931

Description

@davidhodge931

With the DEV version of ggplot2

library(tidyverse)

update_geom_defaults("bar", aes(width = 0.1))
update_geom_defaults("errorbar", aes(width = 0.1))

GeomBar$default_aes
#> Aesthetic mapping: 
#> * `colour`    -> NA
#> * `fill`      -> `from_theme(col_mix(ink, paper, 0.35))`
#> * `linewidth` -> `from_theme(borderwidth)`
#> * `linetype`  -> `from_theme(bordertype)`
#> * `alpha`     -> NA
#> * `width`     -> 0.1
GeomErrorbar$default_aes
#> Aesthetic mapping: 
#> * `colour`    -> `from_theme(ink)`
#> * `linewidth` -> `from_theme(linewidth)`
#> * `linetype`  -> `from_theme(linetype)`
#> * `width`     -> 0.1
#> * `alpha`     -> NA

data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
) |>
  ggplot(aes(
    x = trt,
    y = resp,
    ymin = lower,
    ymax = upper,
    colour = group,
    fill = group,
  )) +
  geom_col(position = "dodge") +
  geom_errorbar(position = "dodge")

Created on 2024-12-10 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions