ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

element_geom use of linewidth & borderwidth etc

Open davidhodge931 opened this issue 4 months ago • 1 comments

Looking at element_geom, I noticed a couple of things:

  1. linewidth/linetype and borderwidth/borderwidth doesn't seem internally consistent.. See example code below. Not sure how to fix this..
  2. Likewise, I think it'd be more intuitive if argument names in element_geom names would map to aesthethetics as much as possible. So I think pointsize sould instead be size etc with a separate element_geom_font function.
library(tidyverse)

p <- ggplot(economics, aes(date)) +
  geom_density()

#would expect this to work
ggplot(economics, aes(date)) +
  geom_density() +
  theme(
    geom.density = element_geom(
      linewidth = 5,
      linetype = 3
    )
  )


#given you can do this
ggplot(economics, aes(date)) +
  geom_density(
    linewidth = 5,
    linetype = 3
  )


#instead have to do this
ggplot(economics, aes(date)) +
  geom_density() +
  theme(
    geom.density = element_geom(
      borderwidth = 5,
      bordertype = 3
    )
  )


#but you can't do this
ggplot(economics, aes(date)) +
  geom_density(
    borderwidth = 5,
    bordertype = 3
  )
#> Warning in geom_density(borderwidth = 5, bordertype = 3): Ignoring unknown
#> parameters: `borderwidth` and `bordertype`

Created on 2025-06-17 with reprex v2.1.1

davidhodge931 avatar Jun 16 '25 23:06 davidhodge931