Skip to content

Commit 0020348

Browse files
committed
add to vignette; better check for list of plots
1 parent 81bcdd5 commit 0020348

File tree

10 files changed

+114
-78
lines changed

10 files changed

+114
-78
lines changed

R/subplots.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
3434
titleY = shareY, which_layout = "merge") {
3535
# are the dots a list of plotly objects?
3636
dotz <- list(...)
37-
if (length(dotz) == 1 && is.list(dotz) && !is.plotly(dotz)) {
37+
if (length(dotz) == 1 && is.list(dotz[[1]]) && !is.plotly(dotz[[1]])) {
3838
dotz <- dotz[[1]]
3939
}
4040
# build each plot

man/gg2list.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ggplotly.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/intro.Rmd

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -161,46 +161,3 @@ To change the default symbols used, use the symbols argument. All the valid symb
161161
plot_ly(iris, x = Petal.Length, y = Petal.Width, mode = "markers",
162162
symbol = Species, symbols = c("cross", "square", "triangle-down"))
163163
```
164-
165-
166-
### The group argument and `subplot()`
167-
168-
Using the group argument splits the data into different plotly "traces".
169-
170-
```{r}
171-
plot_ly(iris, x = Petal.Length, y = Petal.Width,
172-
group = Species, mode = "markers")
173-
```
174-
175-
Although we haven't specified a coloring scheme, plotly will employ one on it's own default scheme. The group argument is quite powerful when used in conjunction with `subplot()` in order to anchor traces onto different axes.
176-
177-
```{r}
178-
iris$id <- as.integer(iris$Species)
179-
p <- plot_ly(iris, x = Petal.Length, y = Petal.Width, group = Species,
180-
xaxis = paste0("x", id), mode = "markers")
181-
subplot(p)
182-
```
183-
184-
Since `subplot()` does not assume x/y axes are on a common scale, it does not impose any restrictions on the range by default. However, you can change this by pre-specifying the range of the [axis objects](https://plot.ly/r/reference/#xaxis) via the `layout()` function.
185-
186-
```{r}
187-
p2 <- layout(
188-
p,
189-
xaxis = list(range = range(Petal.Length) + c(-0.1, 0.1)),
190-
yaxis = list(range = range(Petal.Width) + c(-0.1, 0.1))
191-
)
192-
subplot(p2)
193-
```
194-
195-
Part of the magic of `subplot()` is that it generates axis objects with appropriate anchor and domain properties. After generating a subplot, you can always reference these axis objects to customize each plot.
196-
197-
```{r}
198-
layout(
199-
subplot(p2),
200-
yaxis2 = list(title = ""),
201-
yaxis3 = list(title = "")
202-
)
203-
```
204-
205-
206-
[See here](https://plot.ly/r/map-subplots-and-small-multiples/) for another example of using the group argument to make small multiples (with maps!).

vignettes/proportions.svg

Lines changed: 2 additions & 0 deletions
Loading

vignettes/proportions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36" version="5.5.0.1" editor="www.draw.io" type="device"><diagram>7VpLb+MgEP41kXYvkR9pHsemr72sVKmH3T1SQ2xUYiLsNOn++g72YGPjtpGaxtF6c4jggxkm3wwwQEbh1Xp/p8gm+SkpE6PAo/tReD0Kgtl8Ad8aeCmBi9AvgVhxWkIW8MD/MgQ9RLecsqzRMZdS5HzTBCOZpizKGxhRSu6a3VZSNEfdkNiMWAMPEREu+ovTPEF0juZp/AfjcYIjBx42PJLoKVZym+JwoyBcFZ+yeU2MKuyfJYTKnQWFN8CqkhIU69J6f8WEZtawVsrdvtFama1Yiqa9LwBNWuCZiC3+crQrfzFU7BKes4cNiXR9B94ehcskXwuo+VBccSGupJAK6qlModMSdTKVM4yHDrsKCI26Y3LNcvUCXVAgCEsJDB9D1672hYGShhswAtD7caW3pgAKyEI3I7MzZWQy74sR/+JMKfGbQeKbxcPixJ92kGJm8adImX5MiuDFL6VcwRLFZQpoJrfatA+4yX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