Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

POC: Alternative way of determining parameters#6101

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
teunbrand wants to merge7 commits intotidyverse:main
base:main
Choose a base branch
Loading
fromteunbrand:alt_params

Conversation

teunbrand
Copy link
Collaborator

@teunbrandteunbrand commentedSep 12, 2024
edited
Loading

This PR explores tofix#1516.

It follows the approach proposed in#1516 (comment).
I've numbered the comments in the code below so it'd be easier to follow.

This PR is currently only implemented for 1 stat and 2 geoms, complying with 'a minimal version' of the approach.
It is for this reason still a POC, and we still have to decide if we like this approach.

Comment on lines +66 to +67
default_params = NULL,

Copy link
CollaboratorAuthor

@teunbrandteunbrandSep 12, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. The Geom and Stat classes have a new field that can hold a named list of default parameters.

Comment on lines +214 to +216
if (!is.null(self$default_params)) {
return(names(self$default_params))
}
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. We simply return the name of the default parameter list for checkinglayer() input. For backward compatibility, if this list isn't present, we resort to the old way of determining input.

Comment on lines +433 to +434
params <- defaults(c(self$geom_params, self$aes_params), self$geom$default_params)
self$computed_geom_params <- self$geom$setup_params(data, params)
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. Before we add computed components to the parameters, we initialise the parameters from the new field

@@ -79,7 +81,7 @@ Geom <- ggproto("Geom",
}

# Trim off extra parameters
params <-params[intersect(names(params), self$parameters())]
params <-filter_args(params, self$draw_panel)
Copy link
CollaboratorAuthor

@teunbrandteunbrandSep 12, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. We then filter the parameters on the go in thecompute/draw_layer() andcompute/draw_panel() methods. Implementation offilter_args() in the utils file.

Comment on lines +76 to +77
default_params = NULL,

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. We take the same approach with Stats

Comment on lines +184 to +188
default_params = list(
na.rm = FALSE, orientation = NA,
fun.data = NULL, fun = NULL, fun.max = NULL, fun.min = NULL,
fun.args = list()
),
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. As an example stat, here is how we could implement the default parameters forStatSummary

Comment on lines +181 to +187
default_params = list(
na.rm = FALSE, width = NULL, orientation = NA, outliers = TRUE,
lineend = "butt", linejoin = "mitre", fatten = 2, outlier.colour = NULL,
outlier.fill = NULL, outlier.shape = NULL, outlier.size = NULL,
outlier.stroke = 0.5, outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5,
staplewidth = 0, varwidth = FALSE, flipped_aes = FALSE
),
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. As a geom example, here is how we could implement the default parameter list forGeomBoxplot

}

ggname("geom_violin", grobTree(
GeomPolygon$draw_panel(newdata,...),
inject(GeomPolygon$draw_panel(newdata,!!!params)),
Copy link
CollaboratorAuthor

@teunbrandteunbrandSep 12, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. Here is a downside of the method: we cannot simply pass dots here as GeomViolin recieves more parameters than GeomPolygon needs. This was the only Geom where this was a problem though.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Better way of handling parameters
1 participant
@teunbrand

[8]ページ先頭

©2009-2025 Movatter.jp