Skip to content

element_geom use of linewidth & borderwidth etc #6512

Open
@davidhodge931

Description

@davidhodge931

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

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