Skip to content

Commit cf0b97e

Browse files
Update gganimate
1 parent 2d71b13 commit cf0b97e

File tree

10 files changed

+467
-61
lines changed

10 files changed

+467
-61
lines changed

gganimate.Rmd

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@ title: "ggplot2 extensions: gganimate"
33
---
44

55
### gganimate
6-
<https://github.com/dgrtwo/gganimate>
6+
<https://github.com/thomasp85/gganimate>
77

8-
gganimate wraps the animation package to create animated ggplot2 plots.
9-
10-
```{r eval = FALSE}
11-
knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.show = "animate")
12-
# Example from https://github.com/dgrtwo/gganimate
13-
library(ggplot2)
8+
A Grammar of Animated Graphics.
9+
10+
```{r}
1411
library(gganimate)
15-
16-
# For example, suppose we wanted to create an animation similar to the Gapminder
17-
# world animation, using Jenny Bryan's gapminder package for the data.
1812
library(gapminder)
1913
20-
theme_set(theme_bw())
21-
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
22-
geom_point() +
23-
scale_x_log10()
24-
25-
# Notice we added frame = year and saved the plot as p.
26-
# We then display it as an animation with the gg_animate function:
27-
gg_animate(p)
14+
ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
15+
geom_point(alpha = 0.7, show.legend = FALSE) +
16+
scale_colour_manual(values = country_colors) +
17+
scale_size(range = c(2, 12)) +
18+
scale_x_log10() +
19+
facet_wrap(~continent) +
20+
# Here comes the gganimate specific bits
21+
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
22+
transition_time(year) +
23+
ease_aes('linear')
2824
```
2925

30-
![unnamed-chunk-3](images/output.gif)

gganimate.html

Lines changed: 169 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44

55
<head>
66

7-
<meta charset="utf-8">
7+
<meta charset="utf-8" />
88
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
99
<meta name="generator" content="pandoc" />
1010

1111

1212

13+
1314
<title>ggplot2 extensions: gganimate</title>
1415

15-
<script src="libs/jquery-1.11.0/jquery.min.js"></script>
16+
<script src="libs/jquery-1.11.3/jquery.min.js"></script>
1617
<meta name="viewport" content="width=device-width, initial-scale=1" />
17-
<link href="libs/bootstrap-3.3.1/css/cosmo.min.css" rel="stylesheet" />
18-
<script src="libs/bootstrap-3.3.1/js/bootstrap.min.js"></script>
19-
<script src="libs/bootstrap-3.3.1/shim/html5shiv.min.js"></script>
20-
<script src="libs/bootstrap-3.3.1/shim/respond.min.js"></script>
18+
<link href="libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
19+
<script src="libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
20+
<script src="libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
21+
<script src="libs/bootstrap-3.3.5/shim/respond.min.js"></script>
22+
<script src="libs/navigation-1.1/tabsets.js"></script>
23+
<link href="libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
24+
<script src="libs/highlightjs-9.12.0/highlight.js"></script>
2125

2226
<!-- Styles for this site -->
2327
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -28,25 +32,51 @@
2832
<script src="js/polyfill.js"></script>
2933

3034
<style type="text/css">code{white-space: pre;}</style>
31-
<link rel="stylesheet"
32-
href="libs/highlight/textmate.css"
33-
type="text/css" />
34-
<script src="libs/highlight/highlight.js"></script>
3535
<style type="text/css">
3636
pre:not([class]) {
3737
background-color: white;
3838
}
3939
</style>
4040
<script type="text/javascript">
41-
if (window.hljs && document.readyState && document.readyState === "complete") {
42-
window.setTimeout(function() {
43-
hljs.initHighlighting();
44-
}, 0);
41+
if (window.hljs) {
42+
hljs.configure({languages: []});
43+
hljs.initHighlightingOnLoad();
44+
if (document.readyState && document.readyState === "complete") {
45+
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
46+
}
4547
}
4648
</script>
4749

4850

4951

52+
<style type="text/css">
53+
h1 {
54+
font-size: 34px;
55+
}
56+
h1.title {
57+
font-size: 38px;
58+
}
59+
h2 {
60+
font-size: 30px;
61+
}
62+
h3 {
63+
font-size: 24px;
64+
}
65+
h4 {
66+
font-size: 18px;
67+
}
68+
h5 {
69+
font-size: 16px;
70+
}
71+
h6 {
72+
font-size: 12px;
73+
}
74+
.table th:not([align]) {
75+
text-align: left;
76+
}
77+
</style>
78+
79+
5080
</head>
5181

5282
<body>
@@ -61,13 +91,101 @@
6191
color: inherit;
6292
background-color: rgba(0, 0, 0, 0.04);
6393
}
64-
img {
65-
max-width:100%;
66-
height: auto;
94+
img {
95+
max-width:100%;
96+
height: auto;
97+
}
98+
.tabbed-pane {
99+
padding-top: 12px;
100+
}
101+
.html-widget {
102+
margin-bottom: 20px;
103+
}
104+
button.code-folding-btn:focus {
105+
outline: none;
106+
}
107+
summary {
108+
display: list-item;
67109
}
68110
</style>
111+
112+
113+
69114
<div class="container-fluid main-container">
70115

116+
<!-- tabsets -->
117+
118+
<style type="text/css">
119+
.tabset-dropdown > .nav-tabs {
120+
display: inline-table;
121+
max-height: 500px;
122+
min-height: 44px;
123+
overflow-y: auto;
124+
background: white;
125+
border: 1px solid #ddd;
126+
border-radius: 4px;
127+
}
128+
129+
.tabset-dropdown > .nav-tabs > li.active:before {
130+
content: "";
131+
font-family: 'Glyphicons Halflings';
132+
display: inline-block;
133+
padding: 10px;
134+
border-right: 1px solid #ddd;
135+
}
136+
137+
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
138+
content: "&#xe258;";
139+
border: none;
140+
}
141+
142+
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
143+
content: "";
144+
font-family: 'Glyphicons Halflings';
145+
display: inline-block;
146+
padding: 10px;
147+
border-right: 1px solid #ddd;
148+
}
149+
150+
.tabset-dropdown > .nav-tabs > li.active {
151+
display: block;
152+
}
153+
154+
.tabset-dropdown > .nav-tabs > li > a,
155+
.tabset-dropdown > .nav-tabs > li > a:focus,
156+
.tabset-dropdown > .nav-tabs > li > a:hover {
157+
border: none;
158+
display: inline-block;
159+
border-radius: 4px;
160+
}
161+
162+
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
163+
display: block;
164+
float: none;
165+
}
166+
167+
.tabset-dropdown > .nav-tabs > li {
168+
display: none;
169+
}
170+
</style>
171+
172+
<script>
173+
$(document).ready(function () {
174+
window.buildTabsets("TOC");
175+
});
176+
177+
$(document).ready(function () {
178+
$('.tabset-dropdown > .nav-tabs > li').click(function () {
179+
$(this).parent().toggleClass('nav-tabs-open')
180+
});
181+
});
182+
</script>
183+
184+
<!-- code folding -->
185+
186+
187+
188+
71189
<!--html_preserve-->
72190

73191
<div class="header">
@@ -181,30 +299,7 @@ <h5 class="list-group-item-heading">ggseas</h5>
181299

182300
</div> <!-- col-sm-4 -->
183301

184-
185-
<div id="gganimate" class="col-sm-8">
186-
<h3>gganimate</h3>
187-
<p><a href="https://github.com/dgrtwo/gganimate" class="uri">https://github.com/dgrtwo/gganimate</a></p>
188-
<p>gganimate wraps the animation package to create animated ggplot2 plots.</p>
189-
<pre class="r"><code>knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.show = &quot;animate&quot;)
190-
# Example from https://github.com/dgrtwo/gganimate
191-
library(ggplot2)
192-
library(gganimate)
193-
194-
# For example, suppose we wanted to create an animation similar to the Gapminder
195-
# world animation, using Jenny Bryan&#39;s gapminder package for the data.
196-
library(gapminder)
197-
198-
theme_set(theme_bw())
199-
p &lt;- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
200-
geom_point() +
201-
scale_x_log10()
202-
203-
# Notice we added frame = year and saved the plot as p.
204-
# We then display it as an animation with the gg_animate function:
205-
gg_animate(p)</code></pre>
206-
<p><img src="images/output.gif" alt="unnamed-chunk-3" /></p>
207-
</div> <!-- col-sm-8 -->
302+
<div class="col-sm-8" id="page-body"></div> <!-- col-sm-8 -->
208303

209304
</div> <!-- row -->
210305
</div>
@@ -215,9 +310,35 @@ <h3>gganimate</h3>
215310

216311
<!--/html_preserve-->
217312

313+
<div class="fluid-row" id="header">
218314

219315

220316

317+
<h1 class="title toc-ignore">ggplot2 extensions: gganimate</h1>
318+
319+
</div>
320+
321+
322+
<div id="gganimate" class="section level3">
323+
<h3>gganimate</h3>
324+
<p><a href="https://github.com/thomasp85/gganimate" class="uri">https://github.com/thomasp85/gganimate</a></p>
325+
<p>A Grammar of Animated Graphics.</p>
326+
<pre class="r"><code>library(gganimate)</code></pre>
327+
<pre><code>## Loading required package: ggplot2</code></pre>
328+
<pre class="r"><code>library(gapminder)
329+
330+
ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
331+
geom_point(alpha = 0.7, show.legend = FALSE) +
332+
scale_colour_manual(values = country_colors) +
333+
scale_size(range = c(2, 12)) +
334+
scale_x_log10() +
335+
facet_wrap(~continent) +
336+
# Here comes the gganimate specific bits
337+
labs(title = &#39;Year: {frame_time}&#39;, x = &#39;GDP per capita&#39;, y = &#39;life expectancy&#39;) +
338+
transition_time(year) +
339+
ease_aes(&#39;linear&#39;)</code></pre>
340+
<p><img src="gganimate_files/figure-html/unnamed-chunk-1-1.gif" /><!-- --></p>
341+
</div>
221342

222343

223344
</div> <!-- page-body -->
@@ -266,15 +387,21 @@ <h3>gganimate</h3>
266387

267388
</script>
268389

390+
391+
269392
</div>
270393

271394
<script>
272395

273396
// add bootstrap table styles to pandoc tables
274-
$(document).ready(function () {
397+
function bootstrapStylePandocTables() {
275398
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
399+
}
400+
$(document).ready(function () {
401+
bootstrapStylePandocTables();
276402
});
277403

404+
278405
</script>
279406

280407

Loading

libs/bootstrap-3.3.5/css/darkly.min.css

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/highlightjs-9.12.0/default.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.hljs-literal {
2+
color: #990073;
3+
}
4+
5+
.hljs-number {
6+
color: #099;
7+
}
8+
9+
.hljs-comment {
10+
color: #998;
11+
font-style: italic;
12+
}
13+
14+
.hljs-keyword {
15+
color: #900;
16+
font-weight: bold;
17+
}
18+
19+
.hljs-string {
20+
color: #d14;
21+
}

libs/highlightjs-9.12.0/highlight.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/highlightjs-9.12.0/textmate.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.hljs-literal {
2+
color: rgb(88, 72, 246);
3+
}
4+
5+
.hljs-number {
6+
color: rgb(0, 0, 205);
7+
}
8+
9+
.hljs-comment {
10+
color: rgb(76, 136, 107);
11+
}
12+
13+
.hljs-keyword {
14+
color: rgb(0, 0, 255);
15+
}
16+
17+
.hljs-string {
18+
color: rgb(3, 106, 7);
19+
}

0 commit comments

Comments
 (0)