Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: plotly
Title: Create interactive web-based graphs via plotly's API
Version: 1.0.5
Version: 1.0.6
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cph"),
email = "chris@plot.ly"),
person("Scott", "Chamberlain", role = "aut",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.0.6 -- 25 Aug 2015

Fix a bug with subplot domain calculations (see https://github.com/ropensci/plotly/pull/274)

1.0.5 -- 20 Aug 2015

Fix issue converting plotly offline markdown documents to HTML when using `markdown::markdownToHTML`
Expand Down
4 changes: 2 additions & 2 deletions R/subplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
# (I don't think it makes sense to support partial specification of domains)
if (all(is.na(with(p_info, c(xstart, xend, ystart, yend))))) {
doms <- get_domains(max(p_info$key), nrows, margin)
doms$plot <- as.character(seq_len(nrow(doms)))
doms$key <- as.character(seq_len(nrow(doms)))
p_info <- p_info[!names(p_info) %in% c("xstart", "xend", "ystart", "yend")]
p_info <- plyr::join(p_info, doms, by = "plot")
p_info <- plyr::join(p_info, doms, by = "key")
}
# empty plot container that we'll fill up with new info
p <- list(
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-plotly-subplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ test_that("nrows argument works", {
expect_true(doms$yaxis[1] >= doms$yaxis2[2])
})

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