-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Let Layer$compute_geom_2()
handle legend defaults
#5903
Conversation
|
||
# If `geometry` is not a symbol, `LayerSf$setup_layer()` gives up guessing | ||
# the legend type, and falls back to "polygon" | ||
p <- ggplot_build( | ||
ggplot(d_sf) + geom_sf(aes(geometry = identity(g_point), colour = "a")) | ||
) | ||
expect_identical(p$plot$layers[[1]]$computed_geom_params$legend, "polygon") |
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 legend type is now correctly determined to be a point type, so this test became vestigial
data$.draw <- keep_key_data(params$key, df, matched_aes, layer$show.legend) | ||
} else { | ||
reps <- rep(1, nrow(params$key)) | ||
data <- layer$geom$use_defaults(NULL, layer$aes_params)[reps, ] |
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 visual test for the non-sf legend is to cover this case, which gets solved by Layer$compute_geom_2()
now, but was never triggered in the test suite.
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.
LGTM
This PR is an amendment to #5834, as it didn't handle the non-standard defaults for
geom_sf()
legends.Briefly, this PR let's
Layer$compute_geom_2()
instead ofGeom$use_defaults()
handle populating legend keys with defaults.The legend code was mirroring
Layer$compute_geom_2()
in many ways anyway, so this shouldn't be much of a stretch.This ensures that the layer could impose some of its non-aesthetic parameters on the legend keys.
That is needed to resolve the defaults for the correct legend type in
geom_sf()
, which we'd need for #5833.In addition the following changes are made:
Layer$compute_geom_2()
now accepts a customparams
object, as legends only pass static aesthetics when they are of length 1.LayerSf$setup_layer()
toLayerSf$compute_geom_1()
. This allows for more readable code and abolishes the statefulcomputed_legend_key_type
field inLayerSf
.geom_sf()
's legend types, because we had detected problems in revdepchecks that weren't covered in our own tests.