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

Scale parameters#6196

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

Open
teunbrand wants to merge18 commits intotidyverse:main
base:main
Choose a base branch
Loading
fromteunbrand:scale_experiment
Open

Conversation

@teunbrand
Copy link
Collaborator

@teunbrandteunbrand commentedNov 22, 2024
edited
Loading

This PR follows up on#4271 and#5444, aiming tofix#4269.

Like before, it aims to provide the convenience of setting some scale parameters, without comitting to a full scale yet.
Unlike#5444, this PR is closer to Claus' approach in#4271.

This PR thescale_params() function that populates a newScalesList$params field. When a new scale is added, it will get updated with the parameters in that field. The update mechanism required the most attention. Every<Scale> class now has aScale$new() method that takes on most of the work thatcontinuous_scale(),discrete_scale(),binned_scale() constructors were doing before. TheScale$update() method is a thin wrapper around this and should resolve gnarly situations (e.g. limit transformation).

In the demo below we can note:

  • the y-limits are appropriately transformed by the sqrt transformation. If we were to use the transform first and then the limits, the result would be the same.
  • We can set parameters for multiple scales at once, like colour/shape.
devtools::load_all("~/packages/ggplot2/")#> ℹ Loading ggplot2p<- ggplot(mpg, aes(displ,hwy,colour=drv,shape=factor(year)))+  geom_point()p+  scale_params("x",breaks= c(2,4,7))+  scale_params("y",limits= c(0,50))+  scale_params("y",transform="sqrt")+  scale_params(c("colour","shape"),guide= guide_legend(ncol=2))

The update mechanism should also recognise invalid updates:

p+ scale_params("colour",foobar="i dont exist")#> Error in `geom_point()`:#> ! Problem while computing aesthetics.#> ℹ Error occurred in the 1st layer.#> Caused by error in `scale_colour_discrete()`:#> ! Cannot update scale with the unknown argument:#> • "foobar"

Created on 2024-11-22 withreprex v2.1.1

jbengler reacted with thumbs up emoji
@teunbrandteunbrand changed the titleScale experimentScale parametersNov 22, 2024
@teunbrand
Copy link
CollaboratorAuthor

This could be a nice editioning carrot

@jbengler
Copy link
Contributor

Just giving this PR a little bit of love ❤️ — I’d be thrilled to see it get implemented!

teunbrand reacted with heart emoji

Merge branch 'main' into scale_experiment# Conflicts:#NAMESPACE#R/plot-construction.R#R/scale-.R#tests/testthat/test-scales.R
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@thomasp85thomasp85thomasp85 left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

Editioning

Development

Successfully merging this pull request may close these issues.

Set common scale parameters outside of the scale function

3 participants

@teunbrand@jbengler@thomasp85

[8]ページ先頭

©2009-2025 Movatter.jp