Skip to content

Compatibility ggplot2 4.0.0 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Contributor

Hi Thomas,

The only issue I could find is related to tidyverse/ggplot2#6279, but it is not a hard fix.

@mrcaseb
Copy link

mrcaseb commented Jul 2, 2025

I think marquee has another problem related to the transition to S7. See https://github.com/teunbrand/ggplot2/blob/9f80c8c7b7bce220604737846956cfa1dbfeb0dc/revdep/problems.md#newly-broken-278

I am interested in the fix as I am in the same boat with my package ggpath, which also implements a element. My issue with the S7 transition is that I think I have to set element_text as parent class which doesn't allow me to add new properties.

element_marquee should have the same issue.

@teunbrand
Copy link
Contributor Author

The revdep problem you point to should be solved by tidyverse/ggplot2#6506.

@mrcaseb
Copy link

mrcaseb commented Jul 2, 2025

But element_marquee still is S3?

library(ggplot2)
library(marquee)

ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  labs(title = "A {.red *marquee*} title\n* Look at this bullet list\n\n* great, huh?") +
  theme_gray(base_size = 6) +
  # element_marquee is S3
  theme(title = element_marquee())
#> Error: `object` must be an <S7_object>, not a S3<element_marquee/element_text/element>

Created on 2025-07-02 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.1 (2025-06-13)
#>  os       macOS Sequoia 15.5
#>  system   aarch64, darwin20
#>  ui       X11
#>  language en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2025-07-02
#>  pandoc   3.4 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>  quarto   1.7.31 @ /usr/local/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  cli            3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#>  digest         0.6.37     2024-08-19 [1] CRAN (R 4.5.0)
#>  dplyr          1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#>  evaluate       1.0.4      2025-06-18 [1] CRAN (R 4.5.0)
#>  farver         2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#>  fastmap        1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#>  fs             1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#>  generics       0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#>  ggplot2      * 3.5.2.9001 2025-06-30 [1] Github (tidyverse/ggplot2@c68d9fc)
#>  glue           1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#>  gtable         0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#>  htmltools      0.5.8.1    2024-04-04 [1] CRAN (R 4.5.0)
#>  knitr          1.50       2025-03-16 [1] CRAN (R 4.5.0)
#>  labeling       0.4.3      2023-08-29 [1] CRAN (R 4.5.0)
#>  lifecycle      1.0.4      2023-11-07 [1] CRAN (R 4.5.0)
#>  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.5.0)
#>  marquee      * 1.0.0      2025-01-20 [1] CRAN (R 4.5.0)
#>  pillar         1.10.2     2025-04-05 [1] CRAN (R 4.5.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#>  R6             2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#>  RColorBrewer   1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#>  reprex         2.1.1      2024-07-06 [1] CRAN (R 4.5.0)
#>  rlang          1.1.6      2025-04-11 [1] CRAN (R 4.5.0)
#>  rmarkdown      2.29       2024-11-04 [1] CRAN (R 4.5.0)
#>  rstudioapi     0.17.1     2024-10-22 [1] CRAN (R 4.5.0)
#>  S7             0.2.0      2024-11-07 [1] CRAN (R 4.5.0)
#>  scales         1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#>  sessioninfo    1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#>  tibble         3.3.0      2025-06-08 [1] CRAN (R 4.5.0)
#>  tidyselect     1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#>  vctrs          0.6.5      2023-12-01 [1] CRAN (R 4.5.0)
#>  withr          3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun           0.52       2025-04-02 [1] CRAN (R 4.5.0)
#>  yaml           2.3.10     2024-07-26 [1] CRAN (R 4.5.0)
#> 
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@teunbrand
Copy link
Contributor Author

Yeah, try installing the dev version again, the session info suggests you're a few commits behind

@mrcaseb
Copy link

mrcaseb commented Jul 2, 2025

Yeah, try installing the dev version again, the session info suggests you're a few commits behind

Sorry, Teun. I am having compilation issues with the dev version but I have a reprex where I can show what I mean even with the CRAN version. I really don't want to be annoying but I need to understand what's going on.

The first example works fine even with the current CRAN version. The second example combines axis.title.x and axis.title.y in axis.title which then triggers the S7 <-> S3 error message. Could you confirm this is no issue in the marquee dev version?

I can also do the same thing in ggtext::element_markdown() and it also errors when doing axis.title
This must be related to ggplot2 in some way?

library(ggplot2)
library(marquee)

# works as intended, even with current CRAN version
p <- ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  labs(
    title = "A **fat Title**",
    y = "Red {.red disp}",
    x = "Blue {.blue mpg}",
  ) +
  theme_gray(base_size = 14)

p +
  theme(
    plot.title = element_marquee(),
    axis.title.x = element_marquee(),
    axis.title.y = element_marquee()
  )

# now combine axis.title.x and axis.title.y in axis.title
# S7 error related to element_marquee
p +
  theme(
    plot.title = element_marquee(),
    axis.title = element_marquee()
  )
#> Error: `object` must be an <S7_object>, not a S3<element_marquee/element_text/element>

I can do the same thing with ggtext and element_markdown()

library(ggplot2)
library(ggtext)

# works as intended, even with current CRAN version
p <- ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  labs(
    title = "A **fat Title**",
    y = "*disp*",
    x = "*mpg*",
  ) +
  theme_gray(base_size = 14)

p +
  theme(
    plot.title = element_markdown(),
    axis.title.x = element_markdown(),
    axis.title.y = element_markdown()
  )

# S7 error related to element_marquee
p +
  theme(
    plot.title = element_markdown(),
    axis.title = element_markdown()
  )
#> Error: `object` must be an <S7_object>, not a S3<element_markdown/element_text/element>

Created on 2025-07-02 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.1 (2025-06-13)
#>  os       macOS Sequoia 15.5
#>  system   aarch64, darwin20
#>  ui       X11
#>  language en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2025-07-02
#>  pandoc   3.4 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>  quarto   1.7.31 @ /usr/local/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  cli            3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#>  commonmark     1.9.5      2025-03-17 [1] CRAN (R 4.5.0)
#>  curl           6.4.0      2025-06-22 [1] CRAN (R 4.5.0)
#>  digest         0.6.37     2024-08-19 [1] CRAN (R 4.5.0)
#>  dplyr          1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#>  evaluate       1.0.4      2025-06-18 [1] CRAN (R 4.5.0)
#>  farver         2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#>  fastmap        1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#>  fs             1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#>  generics       0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#>  ggplot2      * 3.5.2.9001 2025-06-30 [1] Github (tidyverse/ggplot2@c68d9fc)
#>  ggtext       * 0.1.2      2022-09-16 [1] CRAN (R 4.5.0)
#>  glue           1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#>  gridtext       0.1.5      2022-09-16 [1] CRAN (R 4.5.0)
#>  gtable         0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#>  htmltools      0.5.8.1    2024-04-04 [1] CRAN (R 4.5.0)
#>  knitr          1.50       2025-03-16 [1] CRAN (R 4.5.0)
#>  labeling       0.4.3      2023-08-29 [1] CRAN (R 4.5.0)
#>  lifecycle      1.0.4      2023-11-07 [1] CRAN (R 4.5.0)
#>  litedown       0.7        2025-04-08 [1] CRAN (R 4.5.0)
#>  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.5.0)
#>  markdown       2.0        2025-03-23 [1] CRAN (R 4.5.0)
#>  marquee      * 1.0.0      2025-01-20 [1] CRAN (R 4.5.0)
#>  pillar         1.10.2     2025-04-05 [1] CRAN (R 4.5.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#>  R6             2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#>  RColorBrewer   1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#>  Rcpp           1.0.14     2025-01-12 [1] CRAN (R 4.5.0)
#>  reprex         2.1.1      2024-07-06 [1] CRAN (R 4.5.0)
#>  rlang          1.1.6      2025-04-11 [1] CRAN (R 4.5.0)
#>  rmarkdown      2.29       2024-11-04 [1] CRAN (R 4.5.0)
#>  rstudioapi     0.17.1     2024-10-22 [1] CRAN (R 4.5.0)
#>  S7             0.2.0      2024-11-07 [1] CRAN (R 4.5.0)
#>  scales         1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#>  sessioninfo    1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#>  stringi        1.8.7      2025-03-27 [1] CRAN (R 4.5.0)
#>  stringr        1.5.1      2023-11-14 [1] CRAN (R 4.5.0)
#>  tibble         3.3.0      2025-06-08 [1] CRAN (R 4.5.0)
#>  tidyselect     1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#>  vctrs          0.6.5      2023-12-01 [1] CRAN (R 4.5.0)
#>  withr          3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun           0.52       2025-04-02 [1] CRAN (R 4.5.0)
#>  xml2           1.3.8      2025-03-14 [1] CRAN (R 4.5.0)
#>  yaml           2.3.10     2024-07-26 [1] CRAN (R 4.5.0)
#> 
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@teunbrand
Copy link
Contributor Author

Sorry I meant the dev version of ggplot2. The examples you give all run fine with the current ggplot2 main branch, with the exception that the axis.title.x/y elements are element_text() and due to hierarchy override the element_marquee/markdown().

@mrcaseb
Copy link

mrcaseb commented Jul 2, 2025

Sorry I meant the dev version of ggplot2. The examples you give all run fine with the current ggplot2 main branch, with the exception that the axis.title.x/y elements are element_text() and due to hierarchy override the element_marquee/markdown().

Oh lol. Will try latest ggplot2 dev version. Thanks for the help!

@teunbrand
Copy link
Contributor Author

This is just a reminder for @thomasp85.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants