element_geom use of linewidth & borderwidth etc
Author
Looking at element_geom, I noticed a couple of things:
- linewidth/linetype and borderwidth/borderwidth doesn't seem internally consistent.. See example code below. Not sure how to fix this..
- 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
element_geom use of linewidth & borderwidth etc
Author
Looking at element_geom, I noticed a couple of things:
- linewidth/linetype and borderwidth/borderwidth doesn't seem internally consistent.. See example code below. Not sure how to fix this..
- 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