-
Notifications
You must be signed in to change notification settings - Fork 20
Internal settings container #473
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
Merged
vincentarelbundock
merged 55 commits into
grantmcdermott:main
from
vincentarelbundock:internal_settings_v3
Nov 19, 2025
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
300ab23
settings container
vincentarelbundock 17f952b
sanitize_() functions now use settings
vincentarelbundock d138d8d
internal settings: more internal reorg
vincentarelbundock cd77067
sanitize_facet()
vincentarelbundock 17718e7
sanitize_datapoints()
vincentarelbundock 302f20c
some types use settings
vincentarelbundock 134479a
more types use settings vault
vincentarelbundock ce17c17
more types
vincentarelbundock a913e12
minor tinyplot
vincentarelbundock b5cb630
Merge branch 'main' into internal_settings_v3
vincentarelbundock cf0a56d
type_text uses settings container
vincentarelbundock 45a24f6
type_rug uses settings container
vincentarelbundock 6911823
type_ribbon uses settings container
vincentarelbundock fecde66
type_density uses settings container
vincentarelbundock 289c377
type_boxplot uses settings container
vincentarelbundock 9063873
type_splineplot uses settings container
vincentarelbundock 8093b0b
type_barplot uses settings container
vincentarelbundock 166ba73
all types use settings container
vincentarelbundock 8ecb589
type_data() returns settings containers for all types
vincentarelbundock 59ffc47
flip almost works
vincentarelbundock a0f3342
type_bubble.R
vincentarelbundock 75b52e8
lim_args function
vincentarelbundock d09042c
fix barplot axes
vincentarelbundock d75c9f1
lim_args uses settings container
vincentarelbundock 1c4044c
make check passes
vincentarelbundock ccd199c
by_aesthetics
vincentarelbundock 30befef
consolidate legend processing
vincentarelbundock 59c178d
format settings list
vincentarelbundock 6a41a7b
reorg
vincentarelbundock 84cac74
docs
vincentarelbundock 2d9b7fb
fix vignette
vincentarelbundock 4ed4063
by_col and by_bg use settings
vincentarelbundock 19dd28b
by_col + by_bg -> by_aesthetics
vincentarelbundock fc6df93
type_info should go in container settings
vincentarelbundock 552b811
modify_list -> update_settings
vincentarelbundock 813e59c
by_aesthetics() treats by_col and by_bg in the same way as others
vincentarelbundock 612133f
stats::setNames is already imported
vincentarelbundock c52555e
raw_input is not necessary
vincentarelbundock 1fdef88
comments and reorder by_aesthetics.R
vincentarelbundock b0a1e07
update_settings everywhere except 1
vincentarelbundock 033c55e
settings list2env subset
vincentarelbundock e3b4ee7
avoid do.call in type_boxplot
vincentarelbundock 9747199
sanitize_ribbon_alpha
vincentarelbundock f33a6fd
settings: list -> env
vincentarelbundock c47e624
settings: list -> env
vincentarelbundock cd54e7e
settings: list -> env
vincentarelbundock 0674e2e
settings: list -> env
vincentarelbundock b355c2c
cruft
vincentarelbundock e584616
fix R check
vincentarelbundock 656c32c
rename
grantmcdermott 6d27eb3
tweak order and add comments
grantmcdermott 221f825
tweak vignette wording
grantmcdermott 4686c0e
tweaks
grantmcdermott 819e0a7
tweak
grantmcdermott c701699
news item
vincentarelbundock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,4 @@ inst/user2025 | |
| #inst/tinytest/ | ||
| Makefile | ||
| ^.devcontainer | ||
| Rplots.pdf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| swap_elements = function(env, a, b) { | ||
| # Swap two elements in an environment | ||
| val_a = if (exists(a, envir = env, inherits = FALSE)) env[[a]] else NULL | ||
| val_b = if (exists(b, envir = env, inherits = FALSE)) env[[b]] else NULL | ||
|
|
||
| assign(a, val_b, envir = env) | ||
| assign(b, val_a, envir = env) | ||
| } | ||
|
|
||
|
|
||
| swap_columns = function(dp, a, b) { | ||
| va = dp[[a]] | ||
| vb = dp[[b]] | ||
| dp[[a]] = if (!is.null(vb)) vb else NULL | ||
| dp[[b]] = if (!is.null(va)) va else NULL | ||
| dp | ||
| } | ||
|
|
||
|
|
||
| flip_datapoints = function(settings) { | ||
| env2env(settings, environment(), c("flip", "type", "datapoints", "log")) | ||
|
|
||
| assert_flag(flip) | ||
| if (isTRUE(flip)) { | ||
| if (type == "boxplot") { | ||
| # boxplot: let horizontal=TRUE do most work; only swap labels | ||
| swap_elements(settings, "xlab", "ylab") | ||
| } else { | ||
| datapoints = swap_columns(datapoints, "xmin", "ymin") | ||
| datapoints = swap_columns(datapoints, "xmax", "ymax") | ||
| datapoints = swap_columns(datapoints, "x", "y") | ||
|
|
||
| # Swap all the x/y settings in the environment | ||
| swap_elements(settings, "x", "y") | ||
| swap_elements(settings, "xaxb", "yaxb") | ||
| swap_elements(settings, "xaxl", "yaxl") | ||
| swap_elements(settings, "xaxs", "yaxs") | ||
| swap_elements(settings, "xaxt", "yaxt") | ||
| swap_elements(settings, "xlab", "ylab") | ||
| swap_elements(settings, "xlabs", "ylabs") | ||
| swap_elements(settings, "xlim", "ylim") | ||
| swap_elements(settings, "xmax", "ymax") | ||
| swap_elements(settings, "xmin", "ymin") | ||
|
|
||
| if (!is.null(log)) { | ||
| log = chartr("xy", "yx", log) | ||
| assign("log", log, envir = settings) | ||
| } | ||
|
|
||
| # Copy modified datapoints back | ||
| assign("datapoints", datapoints, envir = settings) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,49 @@ | ||
| # calculate limits of each plot | ||
|
|
||
| lim_args = function( | ||
| datapoints, | ||
| xlim, ylim, | ||
| xaxb = NULL, yaxb = NULL, | ||
| xlim_user = FALSE, ylim_user = FALSE, | ||
| type | ||
| ) { | ||
|
|
||
| lim_args = function(settings) { | ||
| env2env( | ||
| settings, | ||
| environment(), | ||
| c( | ||
| "xaxb", "xlabs", "xlim", "null_xlim", | ||
| "yaxb", "ylabs", "ylim", "null_ylim", | ||
| "datapoints", "type" | ||
| ) | ||
| ) | ||
|
|
||
| # For cases where x/yaxb is provided and corresponding x/ylabs is not null... | ||
| # We can subset these here to provide breaks | ||
| if (!is.null(xaxb) && !is.null(xlabs)) { | ||
| xlabs = xlabs[names(xlabs) %in% xaxb] | ||
| xaxb = NULL # don't need this any more | ||
| } | ||
| if (!is.null(yaxb) && !is.null(ylabs)) { | ||
| ylabs = ylabs[names(ylabs) %in% yaxb] | ||
| yaxb = NULL # don't need this any more | ||
| } | ||
|
|
||
| if (is.null(xlim)) { | ||
| xlim = range(c(datapoints[["x"]], datapoints[["xmin"]], | ||
| datapoints[["xmax"]]), finite = TRUE) | ||
| xlim = range(c( | ||
| datapoints[["x"]], datapoints[["xmin"]], | ||
| datapoints[["xmax"]]), finite = TRUE) | ||
| } | ||
| if (is.null(ylim)) { | ||
| ylim = range(c(datapoints[["y"]], datapoints[["ymin"]], | ||
| datapoints[["ymax"]]), finite = TRUE) | ||
| ylim = range(c( | ||
| datapoints[["y"]], datapoints[["ymin"]], | ||
| datapoints[["ymax"]]), finite = TRUE) | ||
| } | ||
|
|
||
| if (identical(type, "boxplot")) { | ||
| xlim = xlim + c(-0.5, 0.5) | ||
| } | ||
|
|
||
| if (!xlim_user && !is.null(xaxb) && type != "spineplot") xlim = range(c(xlim, xaxb)) | ||
| if (!ylim_user && !is.null(yaxb) && type != "spineplot") ylim = range(c(ylim, yaxb)) | ||
|
|
||
| out = list(xlim = xlim, ylim = ylim) | ||
| return(out) | ||
| } | ||
| if (null_xlim && !is.null(xaxb) && type != "spineplot") xlim = range(c(xlim, xaxb)) | ||
| if (null_ylim && !is.null(yaxb) && type != "spineplot") ylim = range(c(ylim, yaxb)) | ||
|
|
||
| # update settings | ||
| env2env( | ||
| environment(), | ||
| settings, | ||
| c("xlim", "ylim", "xlabs", "ylabs", "xaxb", "yaxb") | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.