Skip to content

ggplot2 4.0.0 - deprecations & theme setting #59

@jack-davison

Description

@jack-davison

Hi folks,

I'm a fan of ggthemr (used it for all the figures in my thesis once upon a time!)

First:

library(ggplot2)
library(ggthemr)

ggthemr("flat")
#> Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the ggthemr package.
#>   Please report the issue to the authors.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the ggthemr package.
#>   Please report the issue to the authors.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

ggplot(mtcars) +
  geom_point(aes(x = cyl, y = mpg, color = factor(cyl)))
#> Warning: The `scale_name` argument of `discrete_scale()` is deprecated as of ggplot2
#> 3.5.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

Created on 2025-09-11 with reprex v2.1.1

Further -

https://www.tidyverse.org/blog/2025/09/ggplot2-4-0-0/

The ggplot2 4.0.0 release includes things like being able to set palettes and geom default colours and such like purely using the theme() argument. The README states that ggthemr does three things, all of which may now be possible via theme() now:

...updates the default ggplot2 theme with the specified ggthemr theme by using the ggplot2::theme_set() function.
...modifies the aesthetic defaults for all geoms using the ggplot2::update_geom_defaults() function.
...creates functions for all the different scales in the global environment.

Setting palettes / geom defaults via theme() would likely solve #43 and #55.

There's even discussions about getting rid of update_geom_defaults entirely - tidyverse/ggplot2#6085.

I note ggthemr has not received a commit in 3 years; is the intent to keep supporting ggthemr? I'd be happy to at least fix the deprecation issues, but just want to confirm if it is still a focus for Mikata before I submit a PR.

Cheers,
Jack

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