-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy path2016-02-25-scattergl.Rmd
41 lines (34 loc) · 1.04 KB
/
2016-02-25-scattergl.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
40
41
---
description: How to create plots using WebGL
display_as: basic
language: r
layout: base
name: WebGL vs SVG in R
order: 6
output:
html_document:
highlight: null
keep_md: true
theme: null
permalink: r/webgl-vs-svg/
redirect_from: r/webgl-vs-svg-line-chart/
thumbnail: thumbnail/webgl.jpg
---
```{r, echo = FALSE, message=FALSE}
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
```
# WebGL vs SVG in R
Recent versions of the R package include the `toWebGL()` function, which converts any eligible SVG graph into a WebGL plot. With WebGL, we can render way more elements in the browser.
## WebGL with 50,000 points
```{r}
library(plotly)
p <- ggplot(data = diamonds, aes(x = carat, y = price, color = cut)) +
geom_point(alpha = 0.01)
fig <- ggplotly(p)
fig <- fig %>% toWebGL()
fig
```
## More examples
* [Compare SVG performance to WebGL](https://plotly.com/r/webgl-vs-svg/)
* [WebGL with 1 million points](https://plotly.com/r/webgl-vs-svg-million-points/)
* [WebGL for time series](https://plotly.com/r/webgl-vs-svg-time-series/)