-
Notifications
You must be signed in to change notification settings - Fork 637
Geom errorbar issure 1751 #1779
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 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6556b9f
Fix bug. If is.null(data_xy): Set data_xy to mean of data_xy_min and …
trekonom 8e77da5
Add test. Check geom_errorbar is rendered when y aes is not set.
trekonom 198b251
Fix bug. geom_errobar is now rendered with flipped aes. Add test.
trekonom f66ab6f
Minor fixes. Add explanation and reprex for flipped_aes in geom2trace…
trekonom cc287e1
Update R/layers2traces.R
trekonom 68ebe6a
Add visual test to check that geom_errobar is rendered when y aes is …
trekonom 546d5e8
Add visual test to check that geom_errobar is rendered with flipped aes.
trekonom 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
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,26 @@ | ||
| context("Errorbar") | ||
|
|
||
| test_that("geom_errobar is rendered with flipped aes", { | ||
|
|
||
| df <- dplyr::group_by(iris, Species) | ||
| df <- dplyr::summarise_if(df, is.numeric, list(m = mean, q1 = ~ quantile(.x, .25), q3 = ~ quantile(.x, .75))) | ||
| gp <- ggplot(df, aes(y = Species, xmin = Sepal.Width_q1, xmax = Sepal.Width_q3)) + | ||
| geom_errorbar() | ||
|
|
||
| L <- plotly_build(gp) | ||
|
|
||
| # Tests | ||
| # xmin and xmax equal to ggplot | ||
| expect_equivalent(L[["x"]][["data"]][[1]][["x"]] + L[["x"]][["data"]][[1]][["error_x"]][["array"]], | ||
| ggplot_build(gp)$data[[1]]$xmax) | ||
|
|
||
| expect_equivalent(L[["x"]][["data"]][[1]][["x"]] - L[["x"]][["data"]][[1]][["error_x"]][["arrayminus"]], | ||
| ggplot_build(gp)$data[[1]]$xmin) | ||
| # xmin and xmax equal to data | ||
| expect_equivalent(L[["x"]][["data"]][[1]][["x"]] + L[["x"]][["data"]][[1]][["error_x"]][["array"]], | ||
| df$Sepal.Width_q3) | ||
|
|
||
| expect_equivalent(L[["x"]][["data"]][[1]][["x"]] - L[["x"]][["data"]][[1]][["error_x"]][["arrayminus"]], | ||
| df$Sepal.Width_q1) | ||
|
|
||
| }) |
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,35 @@ | ||
| context("Errorbar") | ||
|
|
||
| test_that("geom_errobar is rendered when y aes is not set", { | ||
|
|
||
| # Example from issue #1751 | ||
| d <- data.frame(auc=c(0.268707482993197,0.571428571428571), | ||
| sup=c(0.407680628614317,0.648343533190079), | ||
| inf=c(0.129734337372078,0.494513609667063), | ||
| Names = c("Firmicutes","Spirochaetes")) | ||
|
|
||
| # Plot with y aes set | ||
| p <- ggplot(d, aes(Names)) + | ||
| geom_errorbar(aes(y = auc, ymin = inf, ymax = sup)) | ||
|
|
||
| L <- plotly_build(p) | ||
|
|
||
| # Plot with y aes not set | ||
| p1 <- ggplot(d, aes(Names)) + | ||
| geom_errorbar(aes(ymin = inf, ymax = sup)) | ||
|
|
||
| L1 <- plotly_build(p1) | ||
|
|
||
| # Tests | ||
| ## array and arrayminus of L and L1 are equivalent | ||
| expect_equivalent(L[["x"]][["data"]][[1]][["error_y"]][["array"]], | ||
| L1[["x"]][["data"]][[1]][["error_y"]][["array"]]) | ||
|
|
||
| expect_equivalent(L[["x"]][["data"]][[1]][["error_y"]][["arrayminus"]], | ||
| L1[["x"]][["data"]][[1]][["error_y"]][["arrayminus"]]) | ||
|
|
||
| ## array equals difference between sup and auc, array equals difference between auc and inf | ||
| expect_equivalent(L1[["x"]][["data"]][[1]]$error_y$array, d$sup - d$auc) | ||
| expect_equivalent(L1[["x"]][["data"]][[1]]$error_y$arrayminus, d$auc - d$inf) | ||
|
|
||
| }) |
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.