Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 892d7c9

Browse files
committed
add R 3d surface lighting docs
1 parent 308fdc1 commit 892d7c9

File tree

2 files changed

+358
-0
lines changed

2 files changed

+358
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
title: 3D Surface Lighting in R | Examples | Plotly
3+
name: 3D Surface Lighting in R
4+
permalink: r/3d-surface-lighting/
5+
description: How to add lighting effects in 3D R Plots.
6+
layout: base
7+
thumbnail: thumbnail/your-tutorial-chart.jpg
8+
language: r
9+
page_type: example_index
10+
has_thumbnail: true
11+
display_as: layout_opt
12+
output:
13+
html_document:
14+
keep_md: true
15+
---
16+
17+
```{r, echo = FALSE, message=FALSE}
18+
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
19+
Sys.setenv("plotly_username"="RPlotBot")
20+
Sys.setenv("plotly_api_key"="q0lz6r5efr")
21+
```
22+
### New to Plotly?
23+
24+
Plotly's R library is free and open source!<br>
25+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
26+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
27+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
28+
29+
### Version Check
30+
31+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
32+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
33+
```{r}
34+
library(plotly)
35+
packageVersion('plotly')
36+
```
37+
38+
### Ambient
39+
40+
```{r, results = 'hide'}
41+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(ambient = 0.2)) %>%
42+
add_surface(showscale=FALSE)
43+
44+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(ambient = 0.9)) %>%
45+
add_surface(showscale=FALSE)
46+
47+
p <- subplot(p1, p2) %>%
48+
layout(title = "Ambient Lighting",
49+
grid = list(rows = 1, columns = 2,
50+
pattern = 'independent'),
51+
scene = list(domain=list(column = 0),
52+
aspectmode='cube'),
53+
scene2 = list(domain=list(column = 1),
54+
aspectmode='cube'))
55+
56+
# Create a shareable link to your chart
57+
# Set up API credentials: https://plot.ly/r/getting-started
58+
chart_link = api_create(p, filename="3d-surface-ambient")
59+
chart_link
60+
```
61+
62+
```{r, echo=FALSE}
63+
chart_link
64+
```
65+
66+
### Roughness
67+
68+
```{r, results = 'hide'}
69+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(roughness = 0.1)) %>%
70+
add_surface(showscale=FALSE)
71+
72+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(roughness = 0.9)) %>%
73+
add_surface(showscale=FALSE)
74+
75+
p <- subplot(p1, p2) %>%
76+
layout(title = "Roughness",
77+
grid = list(rows = 1, columns = 2,
78+
pattern = 'independent'),
79+
scene = list(domain=list(column = 0),
80+
aspectmode='cube'),
81+
scene2 = list(domain=list(column = 1),
82+
aspectmode='cube'))
83+
84+
# Create a shareable link to your chart
85+
# Set up API credentials: https://plot.ly/r/getting-started
86+
chart_link = api_create(p, filename="3d-surface-roughness")
87+
chart_link
88+
```
89+
90+
```{r, echo=FALSE}
91+
chart_link
92+
```
93+
94+
### Diffuse
95+
96+
```{r, results = 'hide'}
97+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(diffuse = 0.1)) %>%
98+
add_surface(showscale=FALSE)
99+
100+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(diffuse = 0.9)) %>%
101+
add_surface(showscale=FALSE)
102+
103+
p <- subplot(p1, p2) %>%
104+
layout(title = "Diffuse Reflection",
105+
grid = list(rows = 1, columns = 2,
106+
pattern = 'independent'),
107+
scene = list(domain=list(column = 0),
108+
aspectmode='cube'),
109+
scene2 = list(domain=list(column = 1),
110+
aspectmode='cube'))
111+
112+
# Create a shareable link to your chart
113+
# Set up API credentials: https://plot.ly/r/getting-started
114+
chart_link = api_create(p, filename="3d-surface-diffuse")
115+
chart_link
116+
```
117+
118+
```{r, echo=FALSE}
119+
chart_link
120+
```
121+
122+
### Specular
123+
124+
```{r, results = 'hide'}
125+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(specular = 0.1)) %>%
126+
add_surface(showscale=FALSE)
127+
128+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(specular = 1.9)) %>%
129+
add_surface(showscale=FALSE)
130+
131+
p <- subplot(p1, p2) %>%
132+
layout(title = "Specular Reflection",
133+
grid = list(rows = 1, columns = 2,
134+
pattern = 'independent'),
135+
scene = list(domain=list(column = 0),
136+
aspectmode='cube'),
137+
scene2 = list(domain=list(column = 1),
138+
aspectmode='cube'))
139+
140+
# Create a shareable link to your chart
141+
# Set up API credentials: https://plot.ly/r/getting-started
142+
chart_link = api_create(p, filename="3d-surface-specular")
143+
chart_link
144+
```
145+
146+
```{r, echo=FALSE}
147+
chart_link
148+
```
149+
150+
### Fresnel
151+
152+
```{r, results = 'hide'}
153+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(fresnel = 0.1)) %>%
154+
add_surface(showscale=FALSE)
155+
156+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(fresnel = 4.5)) %>%
157+
add_surface(showscale=FALSE)
158+
159+
p <- subplot(p1, p2) %>%
160+
layout(title = "Fresnel",
161+
grid = list(rows = 1, columns = 2,
162+
pattern = 'independent'),
163+
scene = list(domain=list(column = 0),
164+
aspectmode='cube'),
165+
scene2 = list(domain=list(column = 1),
166+
aspectmode='cube'))
167+
168+
# Create a shareable link to your chart
169+
# Set up API credentials: https://plot.ly/r/getting-started
170+
chart_link = api_create(p, filename="3d-surface-fresnel")
171+
chart_link
172+
```
173+
174+
```{r, echo=FALSE}
175+
chart_link
176+
```
177+
178+
#Reference
179+
180+
See [https://plot.ly/r/reference/#surface-lighting](https://plot.ly/r/reference/#surface-lighting) for more information and options!
181+
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
title: 3D Surface Lighting in R | Examples | Plotly
3+
name: 3D Surface Lighting in R
4+
permalink: r/3d-surface-lighting/
5+
description: How to add lighting effects in 3D R Plots.
6+
layout: base
7+
thumbnail: thumbnail/your-tutorial-chart.jpg
8+
language: r
9+
page_type: example_index
10+
has_thumbnail: true
11+
display_as: layout_opt
12+
output:
13+
html_document:
14+
keep_md: true
15+
---
16+
17+
18+
### New to Plotly?
19+
20+
Plotly's R library is free and open source!<br>
21+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
22+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
23+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
24+
25+
### Version Check
26+
27+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
28+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
29+
30+
```r
31+
library(plotly)
32+
packageVersion('plotly')
33+
```
34+
35+
```
36+
## [1] '4.8.0.9000'
37+
```
38+
39+
### Ambient
40+
41+
42+
```r
43+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(ambient = 0.2)) %>%
44+
add_surface(showscale=FALSE)
45+
46+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(ambient = 0.9)) %>%
47+
add_surface(showscale=FALSE)
48+
49+
p <- subplot(p1, p2) %>%
50+
layout(title = "Ambient Lighting",
51+
grid = list(rows = 1, columns = 2,
52+
pattern = 'independent'),
53+
scene = list(domain=list(column = 0),
54+
aspectmode='cube'),
55+
scene2 = list(domain=list(column = 1),
56+
aspectmode='cube'))
57+
58+
# Create a shareable link to your chart
59+
# Set up API credentials: https://plot.ly/r/getting-started
60+
chart_link = api_create(p, filename="3d-surface-ambient")
61+
chart_link
62+
```
63+
64+
<iframe src="https://plot.ly/~RPlotBot/5561.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
65+
66+
### Roughness
67+
68+
69+
```r
70+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(roughness = 0.1)) %>%
71+
add_surface(showscale=FALSE)
72+
73+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(roughness = 0.9)) %>%
74+
add_surface(showscale=FALSE)
75+
76+
p <- subplot(p1, p2) %>%
77+
layout(title = "Roughness",
78+
grid = list(rows = 1, columns = 2,
79+
pattern = 'independent'),
80+
scene = list(domain=list(column = 0),
81+
aspectmode='cube'),
82+
scene2 = list(domain=list(column = 1),
83+
aspectmode='cube'))
84+
85+
# Create a shareable link to your chart
86+
# Set up API credentials: https://plot.ly/r/getting-started
87+
chart_link = api_create(p, filename="3d-surface-roughness")
88+
chart_link
89+
```
90+
91+
<iframe src="https://plot.ly/~RPlotBot/5563.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
92+
93+
### Diffuse
94+
95+
96+
```r
97+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(diffuse = 0.1)) %>%
98+
add_surface(showscale=FALSE)
99+
100+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(diffuse = 0.9)) %>%
101+
add_surface(showscale=FALSE)
102+
103+
p <- subplot(p1, p2) %>%
104+
layout(title = "Diffuse Reflection",
105+
grid = list(rows = 1, columns = 2,
106+
pattern = 'independent'),
107+
scene = list(domain=list(column = 0),
108+
aspectmode='cube'),
109+
scene2 = list(domain=list(column = 1),
110+
aspectmode='cube'))
111+
112+
# Create a shareable link to your chart
113+
# Set up API credentials: https://plot.ly/r/getting-started
114+
chart_link = api_create(p, filename="3d-surface-diffuse")
115+
chart_link
116+
```
117+
118+
<iframe src="https://plot.ly/~RPlotBot/5565.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
119+
120+
### Specular
121+
122+
123+
```r
124+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(specular = 0.1)) %>%
125+
add_surface(showscale=FALSE)
126+
127+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(specular = 1.9)) %>%
128+
add_surface(showscale=FALSE)
129+
130+
p <- subplot(p1, p2) %>%
131+
layout(title = "Specular Reflection",
132+
grid = list(rows = 1, columns = 2,
133+
pattern = 'independent'),
134+
scene = list(domain=list(column = 0),
135+
aspectmode='cube'),
136+
scene2 = list(domain=list(column = 1),
137+
aspectmode='cube'))
138+
139+
# Create a shareable link to your chart
140+
# Set up API credentials: https://plot.ly/r/getting-started
141+
chart_link = api_create(p, filename="3d-surface-specular")
142+
chart_link
143+
```
144+
145+
<iframe src="https://plot.ly/~RPlotBot/5567.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
146+
147+
### Fresnel
148+
149+
150+
```r
151+
p1 <- plot_ly(z = ~volcano, scene='scene1', lighting = list(fresnel = 0.1)) %>%
152+
add_surface(showscale=FALSE)
153+
154+
p2 <- plot_ly(z = ~volcano, scene='scene2', lighting = list(fresnel = 4.5)) %>%
155+
add_surface(showscale=FALSE)
156+
157+
p <- subplot(p1, p2) %>%
158+
layout(title = "Fresnel",
159+
grid = list(rows = 1, columns = 2,
160+
pattern = 'independent'),
161+
scene = list(domain=list(column = 0),
162+
aspectmode='cube'),
163+
scene2 = list(domain=list(column = 1),
164+
aspectmode='cube'))
165+
166+
# Create a shareable link to your chart
167+
# Set up API credentials: https://plot.ly/r/getting-started
168+
chart_link = api_create(p, filename="3d-surface-fresnel")
169+
chart_link
170+
```
171+
172+
<iframe src="https://plot.ly/~RPlotBot/5569.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
173+
174+
#Reference
175+
176+
See [https://plot.ly/r/reference/#surface-lighting](https://plot.ly/r/reference/#surface-lighting) for more information and options!
177+

0 commit comments

Comments
 (0)