-
Notifications
You must be signed in to change notification settings - Fork 26
Compatibility ggplot2 400 #129
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
Changes from all commits
801ce09
4a1d035
1c1b45e
cd50b76
b7c63e7
b476fd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,4 +28,7 @@ | |
| systemfonts::register_font("fallback", systemfonts::font_info("")$path[1]) | ||
| } | ||
|
|
||
| # Only register once sf is loaded | ||
| vctrs::s3_register("sf::st_as_grob", "sfc_labelled") | ||
| vctrs::s3_register("sf::st_as_grob", "sfc_textbox") | ||
|
Comment on lines
+31
to
+33
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We didn't register these methods anywhere, but somehow it worked anyway. It is better to register them, and to do that we need to register when {sf} is loaded. We could technically avoid a dependency on {vctrs} for this, but it might have uses in the future and it is a 'free' dependency as ggplot2 also takes it as a dependency. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,9 +37,9 @@ sf_types <- c(GEOMETRY = "other", | |
|
|
||
| sf_defaults <- function() { | ||
|
|
||
| point_aes <- GeomPoint$default_aes | ||
| textpath_aes <- GeomTextpath$default_aes | ||
| polygon_aes <- GeomPolygon$default_aes | ||
| point_aes <- get_geom_defaults(GeomPoint) | ||
| textpath_aes <- get_geom_defaults(GeomTextpath) | ||
| polygon_aes <- get_geom_defaults(GeomPolygon) | ||
|
Comment on lines
+40
to
+42
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also to deal with the unevaluated expressions and the reason we'd require ggplot2 3.5.2 |
||
| polygon_aes$fill <- "grey90" | ||
| polygon_aes$colour <- "grey35" | ||
| collection_aes <- rename(textpath_aes, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # wrapping first and last labels works as expected | ||
|
|
||
| Code | ||
| axis_labels$textpath$label[[9]]$glyph | ||
| Output | ||
| [1] "1" "/" "1" "0" | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| make_label(axis_labels$textpath$label[[9]]$glyph) | ||
| Output | ||
| expression(paste(1, "/", 10)) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,9 @@ test_that("wrapping first and last labels works as expected", { | |
| panel <- out$grobs[[which(out$layout$name == "panel")]] | ||
| axis_labels <- panel$children[[5]]$children[[1]] | ||
|
|
||
| expect_equal(axis_labels$textpath$label[[9]]$glyph, c("1", "/", "1", "0")) | ||
| expect_snapshot( | ||
| axis_labels$textpath$label[[9]]$glyph | ||
| ) | ||
|
Comment on lines
+69
to
+71
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed these to snapshots because there is some type instability across versions. They're not run on CRAN by default, but that is fine. |
||
|
|
||
| out <- ggplot_gtable(ggplot_build( | ||
| p + scale_x_continuous(breaks = seq(1, 10, by = 1), | ||
|
|
@@ -75,6 +77,7 @@ test_that("wrapping first and last labels works as expected", { | |
| panel <- out$grobs[[which(out$layout$name == "panel")]] | ||
| axis_labels <- panel$children[[5]]$children[[1]] | ||
|
|
||
| expect_identical(make_label(axis_labels$textpath$label[[9]]$glyph), | ||
| expression(paste(1, "/", 10))) | ||
| expect_snapshot( | ||
| make_label(axis_labels$textpath$label[[9]]$glyph) | ||
| ) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new ggplot2 version has more unevaluated expressions that take their values from the theme.
We should ideally copy defaults from ggplot2's Geoms wherever we can, but it'd be easier when the new release is out.