Skip to content

Commit 84c9d91

Browse files
committed
finish generating non-shiny interactives
1 parent 53c8aaf commit 84c9d91

File tree

768 files changed

+148019
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

768 files changed

+148019
-156
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ Remotes:
4545
hadley/ggstat,
4646
hadley/emo,
4747
hrbrmstr/albersusa,
48+
hrbrmstr/ggalt,
4849
leeper/slopegraph

animation.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gg <- ggplot(gapminder, aes(gdpPercap, lifeExp, color = continent)) +
1212
ggplotly(gg)
1313
```
1414

15-
```{r animation-ggplotly, echo = FALSE, fig.cap = "(ref:animation-ggplotly)"}
15+
```{r animation-ggplotly, echo = FALSE, fig.cap = "(ref:animation-ggplotly)", out.extra = 'data-url="/interactives/animation-ggplotly.html"'}
1616
knitr::include_graphics("images/animation-ggplotly.png")
1717
```
1818

@@ -35,7 +35,7 @@ base %>%
3535
)
3636
```
3737

38-
```{r animation-opts, echo = FALSE, fig.cap = "(ref:animation-opts)"}
38+
```{r animation-opts, echo = FALSE, fig.cap = "(ref:animation-opts)", out.extra = 'data-url="/interactives/animation-opts.html"'}
3939
knitr::include_graphics("images/animation-opts.png")
4040
```
4141

@@ -53,20 +53,20 @@ base %>%
5353
animation_opts(frame = 1000, transition = 0, redraw = FALSE)
5454
```
5555

56-
```{r animation-factors, echo = FALSE, fig.cap = "(ref:animation-factors)"}
56+
```{r animation-factors, echo = FALSE, fig.cap = "(ref:animation-factors)", out.extra = 'data-url="/interactives/animation-factors.html"'}
5757
knitr::include_graphics("images/animation-factors.png")
5858
```
5959

6060
Both the `frame` and `ids` attributes operate on the trace level -- meaning that we can target specific layers of the graph to be animated. One obvious use case for this is to provide a background which displays every possible frame (which is not animated) and overlay the animated frames onto that background. Figure \@ref(fig:animation-targets) shows the same information as Figure \@ref(fig:animation-opts), but layers animated frames on top of a background of all the frames. As a result, it is easier to put a specific year into a global context.
6161

6262
```r
6363
base %>%
64-
add_markers(color = ~continent, alpha = 0.2, showlegend = F) %>%
64+
add_markers(color = ~continent, alpha = 0.2, alpha_stroke = 0.2, showlegend = F) %>%
6565
add_markers(color = ~continent, frame = ~year, ids = ~country) %>%
6666
animation_opts(1000, redraw = FALSE)
6767
```
6868

69-
```{r animation-targets, echo = FALSE, fig.cap = "(ref:animation-targets)"}
69+
```{r animation-targets, echo = FALSE, fig.cap = "(ref:animation-targets)", out.extra = 'data-url="/interactives/animation-targets.html"'}
7070
knitr::include_graphics("images/animation-targets.png")
7171
```
7272

arranging.Rmd

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ p2 <- plot_ly(economics, x = ~date, y = ~uempmed) %>%
2020
subplot(p1, p2)
2121
```
2222

23-
24-
```{r subplot-simple, echo=FALSE, fig.cap="(ref:subplot-simple)"}
23+
```{r subplot-simple, echo=FALSE, fig.cap="(ref:subplot-simple)", out.extra = 'data-url="/interactives/subplot-simple.html"'}
2524
knitr::include_graphics("images/subplot-simple.svg")
2625
```
2726

@@ -36,7 +35,7 @@ plots <- lapply(vars, function(var) {
3635
subplot(plots, nrows = length(plots), shareX = TRUE, titleX = FALSE)
3736
```
3837

39-
```{r economics, echo=FALSE, fig.cap = "(ref:economics)"}
38+
```{r economics, echo=FALSE, fig.cap = "(ref:economics)", out.extra = 'data-url="/interactives/economics.html"'}
4039
knitr::include_graphics("images/economics.svg")
4140
```
4241

@@ -65,7 +64,7 @@ s <- subplot(
6564
layout(s, showlegend = FALSE)
6665
```
6766

68-
```{r joint, echo = FALSE, fig.cap = "(ref:joint)"}
67+
```{r joint, echo = FALSE, fig.cap = "(ref:joint)", out.extra = 'data-url="/interactives/joint.html"'}
6968
knitr::include_graphics("images/joint.svg")
7069
```
7170

@@ -85,7 +84,7 @@ subplot(
8584
)
8685
```
8786

88-
```{r recursive, echo = FALSE, fig.cap = "(ref:recursive)"}
87+
```{r recursive, echo = FALSE, fig.cap = "(ref:recursive)", out.extra = 'data-url="/interactives/recursive.html"'}
8988
knitr::include_graphics("images/recursive.svg")
9089
```
9190

@@ -117,7 +116,7 @@ subplot(barcharts, margin = 0.01) %>%
117116
colorbar(y = 0.5)
118117
```
119118

120-
```{r map-subplot, echo = FALSE, fig.cap = "(ref:map-subplot)"}
119+
```{r map-subplot, echo = FALSE, fig.cap = "(ref:map-subplot)", out.extra = 'data-url="/interactives/map-subplot.html"'}
121120
knitr::include_graphics("images/map-subplot.svg")
122121
```
123122

@@ -155,7 +154,7 @@ class(pm)
155154
ggplotly(pm)
156155
```
157156

158-
```{r ggpairs, echo = FALSE, fig.cap = "(ref:ggpairs)"}
157+
```{r ggpairs, echo = FALSE, fig.cap = "(ref:ggpairs)", out.extra = 'data-url="/interactives/ggpairs.html"'}
159158
knitr::include_graphics("images/ggpairs.svg")
160159
```
161160

@@ -204,7 +203,7 @@ economics_long %>%
204203
subplot(nrows = NROW(.), shareX = TRUE)
205204
```
206205

207-
```{r subplot-trellis, echo=FALSE, fig.cap = "(ref:subplot-trellis)"}
206+
```{r subplot-trellis, echo=FALSE, fig.cap = "(ref:subplot-trellis)", out.extra = 'data-url="/interactives/subplot-trellis.html"'}
208207
knitr::include_graphics("images/subplot-trellis.svg")
209208
```
210209

@@ -241,8 +240,6 @@ Although **flexdashboard** is a really excellent way to arrange web-based conten
241240

242241
Figure \@ref(fig:flexdashboard-ggplotly) provides an example of embedding `ggplotly()` inside **flexdashboard** [@flexdashboard]. Since **flexdashboard** is an **rmarkdown** template, it automatically comes with many of things that make **rmarkdown** great: ability to produce standalone HTML, integration with other languages, and thoughtful integration with RStudio products like Connect. There are many other things to like about **flexdashboard**, including lots of easy-to-use theming options, multiple pages, storyboards, and even **shiny** integration. Explaining how the **flexdashboard** package actually works is beyond the scope of this book, but you can visit the website for documentation and more examples <https://rmarkdown.rstudio.com/flexdashboard/>.
243242

244-
245-
246243
```{r flexdashboard-ggplotly, echo = FALSE, fig.link="https://plotly-r.com/flexdashboard.html", fig.cap = "(ref:flexdashboard-ggplotly)"}
247244
knitr::include_graphics("images/flexdashboard.png")
248245
```
@@ -266,7 +263,7 @@ fluidPage(
266263
)
267264
```
268265

269-
```{r fluid, echo = FALSE, fig.cap = "(ref:fluid)"}
266+
```{r fluid, echo = FALSE, fig.cap = "(ref:fluid)", out.extra = 'data-url="/interactives/fluid.html"'}
270267
knitr::include_graphics("images/fluid.png")
271268
```
272269

@@ -296,7 +293,7 @@ browsable(div(
296293
))
297294
```
298295

299-
```{r flexbox, echo = FALSE, fig.cap = "(ref:flexbox)"}
296+
```{r flexbox, echo = FALSE, fig.cap = "(ref:flexbox)", out.extra = 'data-url="/interactives/flexbox.html"'}
300297
knitr::include_graphics("images/flexbox.png")
301298
```
302299

docs/animating-views.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ <h2><span class="header-section-number">14.1</span> Animation API</h2>
347347
<span class="st"> </span><span class="kw">scale_x_log10</span>()
348348
<span class="kw">ggplotly</span>(gg)</code></pre>
349349
<div class="figure" style="text-align: center"><span id="fig:animation-ggplotly"></span>
350-
<img src="images/animation-ggplotly.png" alt="Animation of the evolution in the relationship between GDP per capita and life expectancy in numerous countries." width="100%" />
350+
<img src="images/animation-ggplotly.png" alt="Animation of the evolution in the relationship between GDP per capita and life expectancy in numerous countries." width="100%" data-url="/interactives/animation-ggplotly.html" />
351351
<p class="caption">
352352
FIGURE 14.1: Animation of the evolution in the relationship between GDP per capita and life expectancy in numerous countries.
353353
</p>
@@ -368,7 +368,7 @@ <h2><span class="header-section-number">14.1</span> Animation API</h2>
368368
<span class="dt">currentvalue =</span> <span class="kw">list</span>(<span class="dt">prefix =</span> <span class="st">&quot;YEAR &quot;</span>, <span class="dt">font =</span> <span class="kw">list</span>(<span class="dt">color=</span><span class="st">&quot;red&quot;</span>))
369369
)</code></pre>
370370
<div class="figure" style="text-align: center"><span id="fig:animation-opts"></span>
371-
<img src="images/animation-opts.png" alt="Modifying animation defaults with animation_opts(), animation_button(), and animation_slider()." width="100%" />
371+
<img src="images/animation-opts.png" alt="Modifying animation defaults with animation_opts(), animation_button(), and animation_slider()." width="100%" data-url="/interactives/animation-opts.html" />
372372
<p class="caption">
373373
FIGURE 14.2: Modifying animation defaults with <code>animation_opts()</code>, <code>animation_button()</code>, and <code>animation_slider()</code>.
374374
</p>
@@ -384,18 +384,18 @@ <h2><span class="header-section-number">14.1</span> Animation API</h2>
384384
<span class="st"> </span><span class="kw">hide_legend</span>() <span class="op">%&gt;%</span>
385385
<span class="st"> </span><span class="kw">animation_opts</span>(<span class="dt">frame =</span> <span class="dv">1000</span>, <span class="dt">transition =</span> <span class="dv">0</span>, <span class="dt">redraw =</span> <span class="ot">FALSE</span>)</code></pre>
386386
<div class="figure" style="text-align: center"><span id="fig:animation-factors"></span>
387-
<img src="images/animation-factors.png" alt="Animation of GDP per capita versus life expectancy by continent. The ordering of the contintents goes from lowest average (across countries) life expectancy to highest." width="100%" />
387+
<img src="images/animation-factors.png" alt="Animation of GDP per capita versus life expectancy by continent. The ordering of the contintents goes from lowest average (across countries) life expectancy to highest." width="100%" data-url="/interactives/animation-factors.html" />
388388
<p class="caption">
389389
FIGURE 14.3: Animation of GDP per capita versus life expectancy by continent. The ordering of the contintents goes from lowest average (across countries) life expectancy to highest.
390390
</p>
391391
</div>
392392
<p>Both the <code>frame</code> and <code>ids</code> attributes operate on the trace level – meaning that we can target specific layers of the graph to be animated. One obvious use case for this is to provide a background which displays every possible frame (which is not animated) and overlay the animated frames onto that background. Figure <a href="animating-views.html#fig:animation-targets">14.4</a> shows the same information as Figure <a href="animating-views.html#fig:animation-opts">14.2</a>, but layers animated frames on top of a background of all the frames. As a result, it is easier to put a specific year into a global context.</p>
393393
<pre class="sourceCode r"><code class="sourceCode r">base <span class="op">%&gt;%</span>
394-
<span class="st"> </span><span class="kw">add_markers</span>(<span class="dt">color =</span> <span class="op">~</span>continent, <span class="dt">alpha =</span> <span class="fl">0.2</span>, <span class="dt">showlegend =</span> F) <span class="op">%&gt;%</span>
394+
<span class="st"> </span><span class="kw">add_markers</span>(<span class="dt">color =</span> <span class="op">~</span>continent, <span class="dt">alpha =</span> <span class="fl">0.2</span>, <span class="dt">alpha_stroke =</span> <span class="fl">0.2</span>, <span class="dt">showlegend =</span> F) <span class="op">%&gt;%</span>
395395
<span class="st"> </span><span class="kw">add_markers</span>(<span class="dt">color =</span> <span class="op">~</span>continent, <span class="dt">frame =</span> <span class="op">~</span>year, <span class="dt">ids =</span> <span class="op">~</span>country) <span class="op">%&gt;%</span>
396396
<span class="st"> </span><span class="kw">animation_opts</span>(<span class="dv">1000</span>, <span class="dt">redraw =</span> <span class="ot">FALSE</span>)</code></pre>
397397
<div class="figure" style="text-align: center"><span id="fig:animation-targets"></span>
398-
<img src="images/animation-targets.png" alt="Overlaying animated frames on top of a background of all possible frames." width="100%" />
398+
<img src="images/animation-targets.png" alt="Overlaying animated frames on top of a background of all possible frames." width="100%" data-url="/interactives/animation-targets.html" />
399399
<p class="caption">
400400
FIGURE 14.4: Overlaying animated frames on top of a background of all possible frames.
401401
</p>

docs/arranging-views.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ <h2><span class="header-section-number">13.1</span> Arranging plotly objects</h2
351351
<span class="st"> </span><span class="kw">add_lines</span>(<span class="dt">name =</span> <span class="st">&quot;uempmed&quot;</span>)
352352
<span class="kw">subplot</span>(p1, p2)</code></pre>
353353
<div class="figure" style="text-align: center"><span id="fig:subplot-simple"></span>
354-
<img src="images/subplot-simple.svg" alt="The most basic use of subplot() to merge multiple plotly objects into a single plotly object." width="100%" />
354+
<img src="images/subplot-simple.svg" alt="The most basic use of subplot() to merge multiple plotly objects into a single plotly object." width="100%" data-url="/interactives/subplot-simple.html" />
355355
<p class="caption">
356356
FIGURE 13.1: The most basic use of <code>subplot()</code> to merge multiple plotly objects into a single plotly object.
357357
</p>
@@ -364,7 +364,7 @@ <h2><span class="header-section-number">13.1</span> Arranging plotly objects</h2
364364
})
365365
<span class="kw">subplot</span>(plots, <span class="dt">nrows =</span> <span class="kw">length</span>(plots), <span class="dt">shareX =</span> <span class="ot">TRUE</span>, <span class="dt">titleX =</span> <span class="ot">FALSE</span>)</code></pre>
366366
<div class="figure" style="text-align: center"><span id="fig:economics"></span>
367-
<img src="images/economics.svg" alt="Five different economic variables on different y scales and a common x scale. Zoom and pan events in the x-direction are synchronized across plots." width="100%" />
367+
<img src="images/economics.svg" alt="Five different economic variables on different y scales and a common x scale. Zoom and pan events in the x-direction are synchronized across plots." width="100%" data-url="/interactives/economics.html" />
368368
<p class="caption">
369369
FIGURE 13.2: Five different economic variables on different y scales and a common x scale. Zoom and pan events in the x-direction are synchronized across plots.
370370
</p>
@@ -395,7 +395,7 @@ <h2><span class="header-section-number">13.1</span> Arranging plotly objects</h2
395395
<span class="kw">layout</span>(s, <span class="dt">showlegend =</span> <span class="ot">FALSE</span>)</code></pre>
396396
</details>
397397
<div class="figure" style="text-align: center"><span id="fig:joint"></span>
398-
<img src="images/joint.svg" alt="A joint density plot with synchronized axes." width="100%" />
398+
<img src="images/joint.svg" alt="A joint density plot with synchronized axes." width="100%" data-url="/interactives/joint.html" />
399399
<p class="caption">
400400
FIGURE 13.4: A joint density plot with synchronized axes.
401401
</p>
@@ -416,7 +416,7 @@ <h3><span class="header-section-number">13.1.1</span> Recursive subplots</h3>
416416
)</code></pre>
417417
</details>
418418
<div class="figure" style="text-align: center"><span id="fig:recursive"></span>
419-
<img src="images/recursive.svg" alt="Recursive subplots." width="100%" />
419+
<img src="images/recursive.svg" alt="Recursive subplots." width="100%" data-url="/interactives/recursive.html" />
420420
<p class="caption">
421421
FIGURE 13.5: Recursive subplots.
422422
</p>
@@ -449,7 +449,7 @@ <h3><span class="header-section-number">13.1.1</span> Recursive subplots</h3>
449449
<span class="st"> </span><span class="kw">colorbar</span>(<span class="dt">y =</span> <span class="fl">0.5</span>)</code></pre>
450450
</details>
451451
<div class="figure" style="text-align: center"><span id="fig:map-subplot"></span>
452-
<img src="images/map-subplot.svg" alt="Multiple bar charts of US statistics by state in a subplot with a choropleth of population density." width="100%" />
452+
<img src="images/map-subplot.svg" alt="Multiple bar charts of US statistics by state in a subplot with a choropleth of population density." width="100%" data-url="/interactives/map-subplot.html" />
453453
<p class="caption">
454454
FIGURE 13.6: Multiple bar charts of US statistics by state in a subplot with a choropleth of population density.
455455
</p>
@@ -483,7 +483,7 @@ <h4><span class="header-section-number">13.1.2.2</span> Generalized pairs plot</
483483
<span class="co">#&gt; [1] &quot;gg&quot; &quot;ggmatrix&quot;</span>
484484
<span class="kw">ggplotly</span>(pm)</code></pre>
485485
<div class="figure" style="text-align: center"><span id="fig:ggpairs"></span>
486-
<img src="images/ggpairs.svg" alt="A generalized pairs plot made via the ggpairs() function from the GGally package." width="100%" />
486+
<img src="images/ggpairs.svg" alt="A generalized pairs plot made via the ggpairs() function from the GGally package." width="100%" data-url="/interactives/ggpairs.html" />
487487
<p class="caption">
488488
FIGURE 13.8: A generalized pairs plot made via the <code>ggpairs()</code> function from the <strong>GGally</strong> package.
489489
</p>
@@ -533,7 +533,7 @@ <h4><span class="header-section-number">13.1.2.3</span> Trellis displays with <c
533533
<span class="st"> </span><span class="kw">subplot</span>(<span class="dt">nrows =</span> <span class="kw">NROW</span>(.), <span class="dt">shareX =</span> <span class="ot">TRUE</span>)</code></pre>
534534
</details>
535535
<div class="figure" style="text-align: center"><span id="fig:subplot-trellis"></span>
536-
<img src="images/subplot-trellis.svg" alt="Creating a trellis display with subplot()." width="100%" />
536+
<img src="images/subplot-trellis.svg" alt="Creating a trellis display with subplot()." width="100%" data-url="/interactives/subplot-trellis.html" />
537537
<p class="caption">
538538
FIGURE 13.9: Creating a trellis display with <code>subplot()</code>.
539539
</p>
@@ -588,7 +588,7 @@ <h3><span class="header-section-number">13.2.2</span> Bootstrap grid layout</h3>
588588
)
589589
)</code></pre>
590590
<div class="figure" style="text-align: center"><span id="fig:fluid"></span>
591-
<img src="images/fluid.png" alt="Arranging multiple htmlwidgets with fluidPage() from the shiny package." width="100%" />
591+
<img src="images/fluid.png" alt="Arranging multiple htmlwidgets with fluidPage() from the shiny package." width="100%" data-url="/interactives/fluid.html" />
592592
<p class="caption">
593593
FIGURE 13.12: Arranging multiple htmlwidgets with <code>fluidPage()</code> from the <strong>shiny</strong> package.
594594
</p>
@@ -611,7 +611,7 @@ <h3><span class="header-section-number">13.2.3</span> CSS flexbox</h3>
611611
<span class="kw">div</span>(p, <span class="dt">style =</span> <span class="st">&quot;width: 100%; border: solid;&quot;</span>)
612612
))</code></pre>
613613
<div class="figure" style="text-align: center"><span id="fig:flexbox"></span>
614-
<img src="images/flexbox.png" alt="Arranging multiple htmlwidgets with CSS flexbox." width="100%" />
614+
<img src="images/flexbox.png" alt="Arranging multiple htmlwidgets with CSS flexbox." width="100%" data-url="/interactives/flexbox.html" />
615615
<p class="caption">
616616
FIGURE 13.13: Arranging multiple htmlwidgets with CSS flexbox.
617617
</p>
@@ -639,7 +639,7 @@ <h2><span class="header-section-number">13.3</span> Arranging many views</h2>
639639
<div class="figure" style="text-align: center"><span id="fig:trelliscope"></span>
640640
<iframe src="https://player.vimeo.com/video/325778067?title=0&amp;byline=0&amp;portrait=0" width="100%" height="400" frameborder="0" seamless="seamless" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
641641
<p class="caption">
642-
FIGURE 13.14: Using <strong>trelliscopejs</strong> to surface high-dimensional insights related to life expectancy and GDP per capita in various countries. For the interactive, see <a href="https://plotly-r.com/interactives/trelliscope.html" class="uri">https://plotly-r.com/interactives/trelliscope.html</a>
642+
FIGURE 13.14: Using <strong>trelliscopejs</strong> to surface high-dimensional insights related to life expectancy and GDP per capita in various countries. For the interactive, see <a href="https://plotly-r.com/interactives/trelliscope" class="uri">https://plotly-r.com/interactives/trelliscope</a>
643643
</p>
644644
</div>
645645

0 commit comments

Comments
 (0)