-
Notifications
You must be signed in to change notification settings - Fork 25
Compatability with ggplot2 3.6.0 #166
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -189,7 +189,7 @@ test_that("gg_tsdisplay() plots", { | |
list(x = "index", y = "value") | ||
) | ||
|
||
p <- p + ggplot2::labs(x = "x", y = "y", title = "title") | ||
p[[1]] <- p[[1]] + ggplot2::labs(x = "x", y = "y", title = "title") | ||
|
||
p_built <- ggplot2::ggplot_build(p[[1]]) | ||
|
||
|
@@ -267,11 +267,4 @@ test_that("gg_arma() plots", { | |
ggplot2::layer_data(p, 4)$PANEL, | ||
factor(c(rep_along(ar_roots, 1), rep_along(ma_roots, 2))) | ||
) | ||
|
||
p_built <- ggplot2::ggplot_build(p) | ||
|
||
expect_equivalent( | ||
p_built$plot$labels[c("x", "y")], | ||
list(x = "Re(1/root)", y = "Im(1/root)") | ||
) | ||
Comment on lines
-270
to
-276
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. The expected label is derived from the global mapping of the plot, while ggplot2 now prioritises layers for default mappings (so the path geoms is the one to provide x/y). 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. No problem, in this case the code is better updated to return Am I correct in understanding that 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.
It will be mpg/hp in that case. Essentially it goes over the layers one-by-one and picks up the labels, so the order in which aesthetics are evaluated matters. It ignores the global aesthetics because they only matter when they are inherited by a layer. The relevant issue is tidyverse/ggplot2#5894 if you want to read more. 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. Thanks for the reference! I'm not against the change, and I think the relevant issue is well motivated. It seems there could be an issue with using Here's an adapted version of ... +
ggplot2::annotate(
"path", x = cos(seq(0, 2 * pi, length.out = 100)),
y = sin(seq(0, 2 * pi, length.out = 100))
) +
ggplot2::geom_vline(xintercept = 0) +
ggplot2::geom_hline(yintercept = 0) +
geom_point() Removing Full (not so minimal) MRE ( plot_data <- structure(list(
type = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), levels = c("AR roots", "MA roots"), class = "factor"),
root = c(0.743346174645867+0.743346174645867i,
-0.743346174645867+0.743346174645867i, -0.743346174645867-0.743346174645867i,
1.01542975837224-0.272083583726372i, 0.272083583726371+1.01542975837224i,
-1.01542975837224+0.272083583726371i, -0.272083583726371-1.01542975837224i,
1.01542975837224+0.272083583726372i, -0.272083583726372+1.01542975837224i,
-1.01542975837224-0.272083583726372i, 0.272083583726372-1.01542975837224i,
0.743346174645867-0.743346174645868i, 3.89255799705759+6.88853197873318e-16i,
0.7382028071715+0.7382028071715i, -0.877092143351749+0.506389385068237i,
-0.506389385068237-0.877092143351749i, 0.877092143351748-0.506389385068237i,
0.506389385068238+0.877092143351749i, -1.00840378774125+0.270200980569754i,
-0.27020098056976-1.00840378774126i, 1.01277877013646+2.37053503325252e-14i,
-6.48524393002789e-15+1.01277877013648i, -1.01277877013648+1.03769254626384e-15i,
0.270200980569773-1.00840378774126i, 1.00840378774127-0.270200980569749i,
0.270200980569755+1.00840378774126i, -1.00840378774126-0.270200980569754i,
3.1285544130455e-15-1.01277877013649i, 0.877092143351752+0.506389385068235i,
-0.50638938506824+0.877092143351747i, -0.877092143351755-0.506389385068242i,
0.506389385068258-0.877092143351732i, 1.00840378774125+0.270200980569741i,
-0.7382028071715+0.738202807171498i, -0.738202807171499-0.738202807171506i,
0.738202807171505-0.738202807171487i, -0.270200980569757+1.00840378774125i,
1.71020671745964+2.77960735720925e-15i),
UnitCircle = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), levels = c("Outside", "Within"), class = "factor")),
row.names = c(NA, -38L), class = c("tbl_df", "tbl", "data.frame"))
plot_data
library(ggplot2)
ggplot(plot_data, aes(x = Re(1/root), y = Im(1/root),
colour = UnitCircle)) +
ggplot2::annotate(
"path", x = cos(seq(0, 2 * pi, length.out = 100)),
y = sin(seq(0, 2 * pi, length.out = 100))
) +
ggplot2::geom_vline(xintercept = 0) +
ggplot2::geom_hline(yintercept = 0) +
geom_point() +
ggplot2::coord_fixed(ratio = 1) +
facet_grid(cols = vars(type)) 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. Looking into Perhaps it is best if I just add the desired labels into the plot explicitly. 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 like the suggestion and I've added it to tidyverse/ggplot2#6290 |
||
}) |
Uh oh!
There was an error while loading. Please reload this page.