-
Notifications
You must be signed in to change notification settings - Fork 39
/
ggiraph.Rmd
39 lines (30 loc) · 1.13 KB
/
ggiraph.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: "ggplot2 extensions: ggiraph"
---
### ggiraph
<http://davidgohel.github.io/ggiraph/introduction.html>
The ggiraph package let R users to make ggplot interactive. The package is an htmlwidget.
```{r, include=FALSE}
# Example from http://davidgohel.github.io/ggiraph/introduction.html
dataset <- mtcars
```
```{r message=FALSE,warning=FALSE}
library(ggplot2)
library(rvg)
library(ggiraph)
mytheme_main <- theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "#dddddd"),
axis.ticks = element_line(colour = "#dddddd") )
mytheme_map <- theme(
panel.background = element_blank(), axis.title.x = element_blank(),
axis.text = element_blank(), axis.line.x = element_blank(),
axis.line.y = element_blank(), axis.title.y = element_blank(),
axis.ticks.x = element_blank(), axis.ticks.y = element_blank() )
dataset$tooltip <- row.names(dataset)
# geom_point_interactive example
gg_point_1 <- ggplot(dataset, aes(x = disp, y = qsec,
color = wt, tooltip = tooltip ) ) +
geom_point_interactive(size=3)
# htmlwidget call
ggiraph(code = {print(gg_point_1 + mytheme_main)}, width = 7, height = 6)
```