Skip to content

Commit 80007ac

Browse files
committed
a few vignette edits
1 parent 957923c commit 80007ac

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

vignettes/subplot.Rmd

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ knitr::opts_chunk$set(
2121

2222
## Introduction
2323

24-
The `subplot()` function provides a flexible interface for arranging multiple **plotly** plots in a single view. There are a few different ways to use `subplot()`, but the simplest way to pass plotly visualization objects directly to `subplot()`.
24+
The `subplot()` function provides a flexible interface for arranging multiple **plotly** plots in a single view. The simplest way to use it is to pass plotly visualizations directly to `subplot()`.
2525

2626
```{r}
2727
library(plotly)
@@ -54,7 +54,7 @@ Conceptually, `subplot()` provides a way to place a collection of plots into a t
5454
<img src = "proportions.svg" width="200" height="250" />
5555
</div>
5656

57-
This can be quite useful for a number of visualizations, for example, a joint density plot:
57+
This flexibility is quite useful for a number of visualizations, for example, a joint density plot (the new [heatmaply](https://github.com/talgalili/heatmaply) package is another good example).
5858

5959
```{r}
6060
x <- rnorm(100)
@@ -75,11 +75,8 @@ Note that, since `subplot()` returns a plotly object, any [layout attribute](htt
7575

7676
## Recursive subplots
7777

78-
The `subplot()` function is designed to work recursively so that you can have subplots of subplots. This idea is useful when your desired layout doesn't conform to the table structure described in the previous section. In fact, you can think of a subplot of subplots like an excel spreadsheet with merged cells.
78+
The `subplot()` function is designed to work recursively so that you can have subplots of subplots. This idea is useful when your desired layout doesn't conform to the table structure described in the previous section. In fact, you can think of a subplot of subplots like a spreadsheet with merged cells.
7979

80-
<!--
81-
Original
82-
-->
8380
<div align = "center">
8481
<img src = "subplot.svg" width="200" height="300" />
8582
</div>
@@ -94,8 +91,7 @@ s2 <- subplot(plotList(2), shareY = TRUE)
9491
subplot(s1, s2, plot_ly(), nrows = 3, margin = 0.04, heights = c(0.6, 0.3, 0.1))
9592
```
9693

97-
98-
94+
The concept is particularly useful when you want plot(s) in a given row to have different widths from plot(s) in another row.
9995

10096
```{r, fig.height = 6}
10197
# specify some map projection/options
@@ -125,13 +121,11 @@ subplot(
125121
)
126122
```
127123

124+
## ggplot2 subplots
128125

129-
## subplots with ggplot2
130-
131-
132-
The `subplot()` function also understands ggplot2 objects and converts them via `ggplotly()`.
126+
The `subplot()` function also understands ggplot2 objects, and converts them to an interactive web-based version via `ggplotly()` before arranging them in the final layout.
133127

134-
```{r, fig.height = 8}
128+
```{r, fig.height = 6}
135129
e <- tidyr::gather(economics, variable, value, -date)
136130
gg1 <- ggplot(e, aes(date, value)) + geom_line() +
137131
facet_wrap(~variable, scales = "free_y", ncol = 1)
@@ -141,13 +135,13 @@ gg2 <- ggplot(e, aes(factor(1), value)) + geom_violin() +
141135
subplot(gg1, gg2) %>% layout(margin = list(l = 50))
142136
```
143137

144-
The new `subplot()` infrastructure allows `ggplotly()` to understand ggmatrix
138+
This infrastructure allows `ggplotly()` to understand ggmatrix
145139
objects -- the class of object returned by the `ggpairs()` function in the
146140
**GGally** package.
147141

148-
```{r}
149-
pm <- GGally::ggpairs(reshape::tips[, 1:3])
150-
ggplotly(pm, margin = 0.04)
142+
```{r, fig.height = 5}
143+
pm <- GGally::ggpairs(iris)
144+
ggplotly(pm)
151145
```
152146

153147

0 commit comments

Comments
 (0)