-
-
Notifications
You must be signed in to change notification settings - Fork 86
Feature ppc ribbon obspoints #257
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22dba06
first go: points for ppc ribbon
charlesm93 b1c0bfe
Add line or both options
charlesm93 c4732bb
Fix typo
charlesm93 95cb06f
Add line, both options for ribbon and group ribbon.
charlesm93 9713da1
add doc for y_draw
jgabry fca4eab
update visual test svgs
jgabry 3169902
fix typo in doc
jgabry 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 |
---|---|---|
|
@@ -173,14 +173,17 @@ ppc_intervals_grouped <- function(y, | |
|
||
#' @rdname PPC-intervals | ||
#' @export | ||
#' @param y_draw For ribbon plots only, a string specifying how to draw `y`. Can | ||
#' be `"line"` (the default), `"points"`, or `"both"`. | ||
ppc_ribbon <- function(y, | ||
yrep, | ||
x = NULL, | ||
..., | ||
prob = 0.5, | ||
prob_outer = 0.9, | ||
alpha = 0.33, | ||
size = 0.25) { | ||
size = 0.25, | ||
y_draw = c("line", "points", "both")) { | ||
check_ignored_arguments(...) | ||
|
||
data <- ppc_intervals_data( | ||
|
@@ -197,7 +200,8 @@ ppc_ribbon <- function(y, | |
size = size, | ||
grouped = FALSE, | ||
style = "ribbon", | ||
x_lab = label_x(x) | ||
x_lab = label_x(x), | ||
y_draw = y_draw | ||
) | ||
} | ||
|
||
|
@@ -213,7 +217,8 @@ ppc_ribbon_grouped <- function(y, | |
prob = 0.5, | ||
prob_outer = 0.9, | ||
alpha = 0.33, | ||
size = 0.25) { | ||
size = 0.25, | ||
y_draw = c("line", "points", "both")) { | ||
check_ignored_arguments(...) | ||
|
||
data <- ppc_intervals_data( | ||
|
@@ -234,7 +239,8 @@ ppc_ribbon_grouped <- function(y, | |
size = size, | ||
grouped = TRUE, | ||
style = "ribbon", | ||
x_lab = label_x(x) | ||
x_lab = label_x(x), | ||
y_draw = y_draw | ||
) | ||
} | ||
|
||
|
@@ -319,9 +325,11 @@ label_x <- function(x) { | |
size = 1, | ||
grouped = FALSE, | ||
style = c("intervals", "ribbon"), | ||
x_lab = NULL) { | ||
x_lab = NULL, | ||
y_draw = c("line", "points", "both")) { | ||
|
||
style <- match.arg(style) | ||
y_draw <- match.arg(y_draw) | ||
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 added this because the |
||
|
||
graph <- ggplot( | ||
data = data, | ||
|
@@ -349,11 +357,22 @@ label_x <- function(x) { | |
aes_(color = "yrep"), | ||
size = size/2 | ||
) + | ||
geom_blank(aes_(fill = "y")) + | ||
geom_line( | ||
geom_blank(aes_(fill = "y")) | ||
|
||
if (y_draw == "line" || y_draw == "both") { | ||
graph <- graph + geom_line( | ||
aes_(y = ~ y_obs, color = "y"), | ||
size = 0.5 | ||
) | ||
} | ||
|
||
if (y_draw == "points" || y_draw == "both") { | ||
graph <- graph + geom_point( | ||
mapping = aes_(y = ~ y_obs, color = "y", fill = "y"), | ||
shape = 21, | ||
size = 1.5 | ||
) | ||
} | ||
} else { | ||
graph <- graph + | ||
geom_pointrange( | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 +1,3 @@ | ||
- vdiffr-svg-engine: 1.0 | ||
- vdiffr: 0.3.2.2 | ||
- vdiffr: 0.3.3 | ||
- freetypeharfbuzz: 0.2.5 |
174 changes: 174 additions & 0 deletions
174
tests/figs/ppc-intervals-ribbon/ppc-intervals-y-draw-both.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions
72
tests/figs/ppc-intervals-ribbon/ppc-intervals-y-draw-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
171 changes: 171 additions & 0 deletions
171
tests/figs/ppc-intervals-ribbon/ppc-intervals-y-draw-point.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
244 changes: 244 additions & 0 deletions
244
tests/figs/ppc-intervals-ribbon/ppc-ribbon-grouped-default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
236 changes: 236 additions & 0 deletions
236
tests/figs/ppc-intervals-ribbon/ppc-ribbon-grouped-x-values.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
346 changes: 346 additions & 0 deletions
346
tests/figs/ppc-intervals-ribbon/ppc-ribbon-grouped-y-draw-both.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
244 changes: 244 additions & 0 deletions
244
tests/figs/ppc-intervals-ribbon/ppc-ribbon-grouped-y-draw-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
340 changes: 340 additions & 0 deletions
340
tests/figs/ppc-intervals-ribbon/ppc-ribbon-grouped-y-draw-point.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
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.
Not essential, but it's common in R to put all valid options in a vector and then use
match.arg
later to ensure that what the user wrote is a valid option. (See below where I addedmatch.arg
)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.
Makes sense. I was wondering what match.arg does.