Skip to content

Commit 1d56b19

Browse files
committed
Merge pull request #535 from ropensci/fix/errorbars
Use transparent scatter lines for errorbars. Fixes #513.
2 parents 03d3e54 + 2681972 commit 1d56b19

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via 'plotly.js'
3-
Version: 3.4.9
3+
Version: 3.4.10
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NEWS

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
3.4.10 -- 1 Apr 2016
2+
3+
BUGFIX:
4+
5+
Fix a geom_errorbar bug introduced in 3.4.9. See #513.
6+
17
3.4.9 -- 25 Mar 2016
28

39
BUGFIX:
410

511
Upgrade to plotlyjs 1.7.0. Fixes #513
612

7-
813
3.4.8 -- 23 Mar 2016
914

1015
BUGFIX:

R/layers2traces.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ make_error <- function(data, params, xy = "x") {
655655
text = data$hovertext,
656656
type = "scatter",
657657
mode = "lines",
658-
opacity = 0,
659-
line = list(color = color)
658+
opacity = aes2plotly(data, params, "alpha"),
659+
line = list(color = "transparent")
660660
)
661661
e[[paste0("error_", xy)]] <- list(
662662
array = data[[paste0(xy, "max")]] - data[[xy]],

tests/testthat.R

+19-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ if (report_diffs || build_table) {
1212
message("Spinning up an independent R session with plotly's master branch installed")
1313
Rserve::Rserve(args = "--vanilla --RS-enable-remote")
1414
conn <- RSconnect()
15-
# master version should _always_ depend on the CRAN version of ggplot2
15+
# ensure the seed is the same for randomized tests
16+
set.seed(1)
17+
RSeval(conn, "set.seed(1)")
18+
# we don't make assumptions about ggplot2 versioning,
19+
# but it is _strongly_ recommended to use the CRAN version (of ggplot2)
1620
RSeval(conn, "devtools::install_github('ropensci/plotly')")
1721
RSeval(conn, "library(plotly)")
1822
if (report_diffs) {
@@ -23,6 +27,19 @@ if (report_diffs || build_table) {
2327
master_hash <- substr(master_hash, 1, 7)
2428
# plotly-test-table repo hosts the diff pages & keeps track of previous versions
2529
table_dir <- normalizePath("../../plotly-test-table", mustWork = T)
30+
# Make sure we have appropriate versions of plotlyjs
31+
# (see plotly-test-table/template/template/index.html)
32+
file.copy(
33+
file.path("..", "inst", "htmlwidgets", "lib", "plotlyjs", "plotly-latest.min.js"),
34+
file.path(table_dir, "template", "New.min.js"),
35+
overwrite = TRUE
36+
)
37+
download.file(
38+
"https://raw.githubusercontent.com/ropensci/plotly/master/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js",
39+
file.path(table_dir, "template", "Old.min.js"),
40+
method = "curl"
41+
)
42+
# directory for placing test differences
2643
this_dir <- file.path(table_dir, this_hash)
2744
if (dir.exists(this_dir)) {
2845
message("Tests were already run on this commit. Nuking the old results...")
@@ -102,9 +119,7 @@ save_outputs <- function(gg, name) {
102119
dir.create(test_dir, recursive = T)
103120
# copy over diffing template
104121
file.copy(
105-
file.path(table_dir, "template", "template", "index.html"),
106-
test_dir,
107-
recursive = T
122+
dir(file.path(table_dir, "template", "template"), full.names = TRUE), test_dir
108123
)
109124
# overwrite the default JSON
110125
writeLines(

tests/testthat/test-ggplot-jitter.R

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ expect_traces <- function(gg, n_traces, name) {
1515
list(traces = has_data, layout = L$layout)
1616
}
1717

18-
set.seed(1001)
1918
p <- ggplot(mpg, aes(cyl, hwy)) + geom_jitter()
2019

2120
test_that("geom_jitter is working", {

tests/testthat/test-mean-error-bars.R

+18
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ test_that("different colors for error bars, points, and lines", {
3636
geom_point(color = "blue", size = 14)
3737
L <- save_outputs(one.line.gg, "error-simple-line-point-crazy")
3838
})
39+
40+
# example from https://github.com/ropensci/plotly/issues/513
41+
42+
d <- data.frame(
43+
x = 1:5,
44+
y = 1:5,
45+
label = letters[1:5],
46+
group = factor(c('one', 'one', 'two', 'two', 'one'))
47+
)
48+
fig1 <- ggplot(d, aes(x = x, y = y, text = label, colour = group)) +
49+
geom_rect(fill = 'lightgrey', colour = 'lightgrey',
50+
xmin = 3, xmax = 4, ymin = -4, ymax = 7) +
51+
geom_point() + geom_errorbarh(aes(xmin = x - 1, xmax = x + 2), alpha = 0.5) +
52+
theme_bw()
53+
54+
test_that("error bars respect trace ordering", {
55+
L <- save_outputs(fig1, "error-rect-alpha")
56+
})

0 commit comments

Comments
 (0)