Skip to content

Commit 9a5714e

Browse files
committed
Merge pull request #228 from ropensci/marianne-fix-element-aes
Fix element-wise access in for loop
2 parents 3d9a6b7 + 96974fe commit 9a5714e

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via Plotly's JavaScript Graphing Library
3-
Version: 2.0.7
3+
Version: 2.0.8
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.0.8 -- 10 Dec 2015
2+
3+
Fix a bug with geom_segment (see #321 & #228)
4+
15
2.0.7 -- 10 Dec 2015
26

37
Fix #233

R/trace_generation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ layer2traces <- function(l, d, misc) {
5757
aes.used <- aes.names[aes.names %in% names(g$aes)]
5858
for(a in aes.used) {
5959
a.name <- paste0(a, ".name")
60-
col.name <- g$aes[aes.used]
60+
col.name <- g$aes[a.name]
6161
dtemp <- l$data[[col.name]]
6262
if (is.null(dtemp)) {
6363
if (!is.null(g$data[[a.name]])) {

tests/testthat/test-ggplot-segment.R

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,38 @@ test_that("segments become one path", {
1111
tr <- info$data[[1]]
1212
expect_true(any(is.na(tr$x)))
1313
expect_true(any(is.na(tr$y)))
14+
save_outputs(gg, "segment")
15+
})
16+
17+
test_that("with non-numeric data, we can have more than one segment", {
18+
df <- data.frame(donation=c(102.35377, 98.80028, 102.34715, 103.71195,
19+
107.74814, 92.21549, 103.54709, 93.52689,
20+
104.32014, 93.23326, 123.76597, 128.53826,
21+
125.36151, 116.29949, 125.65676, 118.60371,
22+
117.60477, 128.28911, 121.93446, 127.63119,
23+
97.61806, 94.25784, 102.66568, 100.75126,
24+
96.08688, 89.15305, 100.29993, 89.76010,
25+
103.79008, 96.71342, 95.31541, 107.68345,
26+
94.42277, 98.91443, 100.55720, 104.00674,
27+
91.39054, 94.11684, 102.08854, 97.04515),
28+
campaign=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
29+
2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
30+
2, 2, 2, 2, 2, 2))
31+
32+
seg1 <- data.frame(x=0.85, xend=1.15, y=100.2, yend=100.2)
33+
seg2 <- data.frame(x=1.85, xend=2.15, y=123.5, yend=123.5)
34+
35+
gg <- ggplot() +
36+
geom_point(data=df, aes(x=campaign, y=donation, colour=campaign)) +
37+
geom_segment(data=seg1, aes(x, y, xend=xend, yend=yend)) +
38+
geom_segment(data=seg2, aes(x, y, xend=xend, yend=yend))
39+
40+
fig <- gg2list(gg)
41+
expect_equal(length(fig$data), 4)
42+
expect_equal(fig$data[[3]]$x[1], seg1$x)
43+
expect_equal(fig$data[[3]]$x[2], seg1$xend)
44+
expect_equal(fig$data[[4]]$x[1], seg2$x)
45+
expect_equal(fig$data[[4]]$x[2], seg2$xend)
46+
47+
save_outputs(gg, "segment-multiple-non-numeric")
1448
})

0 commit comments

Comments
 (0)