Skip to content

Commit 3a6b9b4

Browse files
committed
Merge pull request #274 from ropensci/subplot-fix
subplot() bugfix
2 parents 12c51d2 + 4bb006e commit 3a6b9b4

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create interactive web-based graphs via plotly's API
3-
Version: 1.0.5
3+
Version: 1.0.6
44
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cph"),
55
email = "[email protected]"),
66
person("Scott", "Chamberlain", role = "aut",

Diff for: NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.0.6 -- 25 Aug 2015
2+
3+
Fix a bug with subplot domain calculations (see https://github.com/ropensci/plotly/pull/274)
4+
15
1.0.5 -- 20 Aug 2015
26

37
Fix issue converting plotly offline markdown documents to HTML when using `markdown::markdownToHTML`

Diff for: R/subplots.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
7979
# (I don't think it makes sense to support partial specification of domains)
8080
if (all(is.na(with(p_info, c(xstart, xend, ystart, yend))))) {
8181
doms <- get_domains(max(p_info$key), nrows, margin)
82-
doms$plot <- as.character(seq_len(nrow(doms)))
82+
doms$key <- as.character(seq_len(nrow(doms)))
8383
p_info <- p_info[!names(p_info) %in% c("xstart", "xend", "ystart", "yend")]
84-
p_info <- plyr::join(p_info, doms, by = "plot")
84+
p_info <- plyr::join(p_info, doms, by = "key")
8585
}
8686
# empty plot container that we'll fill up with new info
8787
p <- list(

Diff for: tests/testthat/test-plotly-subplot.R

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ test_that("nrows argument works", {
2727
expect_true(doms$yaxis[1] >= doms$yaxis2[2])
2828
})
2929

30+
test_that("group + [x/y]axis works", {
31+
iris$id <- as.integer(iris$Species)
32+
p <- plot_ly(iris, x = Petal.Length, y = Petal.Width, group = Species,
33+
xaxis = paste0("x", id), mode = "markers")
34+
s <- expect_traces(subplot(p, margin = 0.05), 3, "group")
35+
doms <- lapply(s$layout, "[[", "domain")
36+
# make sure y domain is [0, 1] on every axis
37+
ydom <- doms[grepl("^y", names(doms))]
38+
expect_equal(sort(unique(unlist(ydom))), c(0, 1))
39+
xdom <- doms[grepl("^x", names(doms))]
40+
expect_true(all(1/3 > xdom[[1]] & xdom[[1]] >= 0))
41+
expect_true(all(2/3 > xdom[[2]] & xdom[[2]] > 1/3))
42+
expect_true(all(1 >= xdom[[3]] & xdom[[3]] > 2/3))
43+
})
3044

3145

3246

0 commit comments

Comments
 (0)