rstudio / thematic

Theme ggplot2, lattice, and base graphics based on a few simple settings.
https://rstudio.github.io/thematic/
Other
244 stars 10 forks source link

Compatibility with ggplot2 3.5.0 #148

Closed teunbrand closed 6 months ago

teunbrand commented 7 months ago

Hi there,

I apologise for not abiding by the checklist. We have been preparing a new release of ggplot2 and during a reverse dependency check, it became apparent that the prospecive ggplot2 3.5.0 would break thematic.

The function that would break checks is the theme_relationships(), as there are now elements that inherit from two parents instead of 1:1 inheritance (minor axis ticks length). The proposed changes herein do not resolve the multiple inheritance, but merely prevents breaking the function.

Here is an example of minor ticks in use with this PR:

devtools::load_all("~/packages/test/thematic/")
#> ℹ Loading thematic
library(ggplot2) # 3.5.0

thematic_local_theme(theme = thematic_theme(fg = "red"))

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  guides(
    x = guide_axis(minor.ticks = TRUE),
    y = guide_axis(minor.ticks = TRUE)
  )

Created on 2024-01-19 with reprex v2.1.0

A second thing we've changed is the resolution of legend text and titles. These are now resolved internally based on the text/title position within the legend, to give these appropriate margins and justifications. The pre-computation of these theme elements in full, renders these internal resolutions void, and legend text/titles would appear misplaced. In this PR, justification and margin overrides for the relevant theme elements has been disabled. This change is not absolutely necessary, but I figured it might be desired.

In addition to aforementioned issues, I think it might be a good idea to review the visual checks and possibly make a decision of whether the new legend.frame, legend.ticks and legend.key.spacing.y elements should also be exempt from pre-computation. This is more of a matter of taste, so I'm not in a position to advise here.

For reasons of unfamiliarity, I wasn't able to judge the shiny tests in any meaningful capacity.

To test the code changes with the release candidate, you can install it with the code below:

remotes::install_github("tidyverse/ggplot2", ref = remotes::github_pull("5592"))

The release of ggplot2 3.5.0 is scheduled for the 12th of February. The progress of the release can be tracked in https://github.com/tidyverse/ggplot2/issues/5588. We hope that this PR might help thematic get out a fix if necessary.

CLAassistant commented 7 months ago

CLA assistant check
All committers have signed the CLA.

teunbrand commented 7 months ago

This is just a kind reminder that the release of ggplot is scheduled soon.

cpsievert commented 6 months ago

This is great, thanks so much!