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

Skip to content

Commit 2999eeb

Browse files
committed
add R isosurface doc
1 parent 8b531ea commit 2999eeb

File tree

2 files changed

+324
-0
lines changed

2 files changed

+324
-0
lines changed

_posts/r/3d/2019-04-16-isosurface.Rmd

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: 3D Isosurface Plots | Plotly
3+
name: 3D Isosurface Plots
4+
permalink: r/3d-isosurface-plots/
5+
description: How to create 3D isosurface plots with Plotly.
6+
layout: base
7+
thumbnail: thumbnail/isosurface.jpg
8+
language: r
9+
has_thumbnail: true
10+
display_as: 3d_charts
11+
order: 20
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+
39+
#### Basic Isosurface Plot
40+
41+
```{r, results = 'hide'}
42+
library(plotly)
43+
44+
p <- plot_ly(
45+
type='isosurface',
46+
x = c(0,0,0,0,1,1,1,1),
47+
y = c(1,0,1,0,1,0,1,0),
48+
z = c(1,1,0,0,1,1,0,0),
49+
value = c(1,2,3,4,5,6,7,8),
50+
isomin=2,
51+
isomax=6
52+
)
53+
54+
# Create a shareable link to your chart
55+
# Set up API credentials: https://plot.ly/r/getting-started
56+
chart_link = api_create(p, filename="isosurface-basic")
57+
chart_link
58+
```
59+
60+
```{r, echo=FALSE}
61+
chart_link
62+
```
63+
64+
#### Isosurface with Additional Slices
65+
66+
```{r, results = 'hide'}
67+
library(plotly)
68+
69+
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/clebsch-cubic.csv')
70+
71+
p <- plot_ly(
72+
df,
73+
type='isosurface',
74+
x = ~x,
75+
y = ~y,
76+
z = ~z,
77+
value = ~value,
78+
isomin = -100,
79+
isomax = 100,
80+
colorscale='RdBu',
81+
surface = list(show = TRUE, count = 1),
82+
slices = list(z = list(
83+
show = TRUE, locations = c(-0.3, 0.5)
84+
)),
85+
caps = list(
86+
x = list(show = FALSE),
87+
y = list(show = FALSE),
88+
z = list(show = FALSE)
89+
)
90+
) %>%
91+
layout(
92+
margin=list(t = 0, l = 0, b = 0),
93+
scene=list(
94+
camera=list(
95+
eye=list(
96+
x = 1.86,
97+
y = 0.61,
98+
z = 0.98
99+
)
100+
)
101+
)
102+
)
103+
104+
# Create a shareable link to your chart
105+
# Set up API credentials: https://plot.ly/r/getting-started
106+
chart_link = api_create(p, filename="isosurface-slices")
107+
chart_link
108+
```
109+
110+
```{r, echo=FALSE}
111+
chart_link
112+
```
113+
114+
#### Multiple Isosurfaces with Caps
115+
116+
```{r, results = 'hide'}
117+
library(plotly)
118+
119+
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/clebsch-cubic.csv')
120+
121+
p <- plot_ly(
122+
df,
123+
type='isosurface',
124+
x = ~x,
125+
y = ~y,
126+
z = ~z,
127+
value = ~value,
128+
isomin = -10,
129+
isomax = 10,
130+
surface = list(show = TRUE, count = 4, fill = 0.8, pattern = 'odd'),
131+
caps = list(
132+
x = list(show = TRUE),
133+
y = list(show = TRUE),
134+
z = list(show = TRUE)
135+
)
136+
) %>%
137+
layout(
138+
margin=list(t = 0, l = 0, b = 0),
139+
scene=list(
140+
camera=list(
141+
eye=list(
142+
x = 1.86,
143+
y = 0.61,
144+
z = 0.98
145+
)
146+
)
147+
)
148+
)
149+
150+
# Create a shareable link to your chart
151+
# Set up API credentials: https://plot.ly/r/getting-started
152+
chart_link = api_create(p, filename="multiple-isosurface-caps")
153+
chart_link
154+
```
155+
156+
```{r, echo=FALSE}
157+
chart_link
158+
```
159+
160+
161+
#### Reference
162+
163+
See our [reference page](https://plot.ly/r/reference/) for more information and chart attribute options!.

_posts/r/3d/2019-04-16-isosurface.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
title: 3D Isosurface Plots | Plotly
3+
name: 3D Isosurface Plots
4+
permalink: r/3d-isosurface-plots/
5+
description: How to create 3D isosurface plots with Plotly.
6+
layout: base
7+
thumbnail: thumbnail/isosurface.jpg
8+
language: r
9+
has_thumbnail: true
10+
display_as: 3d_charts
11+
order: 20
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.9.0'
37+
```
38+
39+
40+
#### Basic Isosurface Plot
41+
42+
43+
```r
44+
library(plotly)
45+
46+
p <- plot_ly(
47+
type='isosurface',
48+
x = c(0,0,0,0,1,1,1,1),
49+
y = c(1,0,1,0,1,0,1,0),
50+
z = c(1,1,0,0,1,1,0,0),
51+
value = c(1,2,3,4,5,6,7,8),
52+
isomin=2,
53+
isomax=6
54+
)
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="isosurface-basic")
59+
chart_link
60+
```
61+
62+
<iframe src="https://plot.ly/~RPlotBot/5639.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
63+
64+
#### Isosurface with Additional Slices
65+
66+
67+
```r
68+
library(plotly)
69+
70+
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/clebsch-cubic.csv')
71+
72+
p <- plot_ly(
73+
df,
74+
type='isosurface',
75+
x = ~x,
76+
y = ~y,
77+
z = ~z,
78+
value = ~value,
79+
isomin = -100,
80+
isomax = 100,
81+
colorscale='RdBu',
82+
surface = list(show = TRUE, count = 1),
83+
slices = list(z = list(
84+
show = TRUE, locations = c(-0.3, 0.5)
85+
)),
86+
caps = list(
87+
x = list(show = FALSE),
88+
y = list(show = FALSE),
89+
z = list(show = FALSE)
90+
)
91+
) %>%
92+
layout(
93+
margin=list(t = 0, l = 0, b = 0),
94+
scene=list(
95+
camera=list(
96+
eye=list(
97+
x = 1.86,
98+
y = 0.61,
99+
z = 0.98
100+
)
101+
)
102+
)
103+
)
104+
105+
# Create a shareable link to your chart
106+
# Set up API credentials: https://plot.ly/r/getting-started
107+
chart_link = api_create(p, filename="isosurface-slices")
108+
chart_link
109+
```
110+
111+
<iframe src="https://plot.ly/~RPlotBot/5641.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
112+
113+
#### Multiple Isosurfaces with Caps
114+
115+
116+
```r
117+
library(plotly)
118+
119+
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/clebsch-cubic.csv')
120+
121+
p <- plot_ly(
122+
df,
123+
type='isosurface',
124+
x = ~x,
125+
y = ~y,
126+
z = ~z,
127+
value = ~value,
128+
isomin = -10,
129+
isomax = 10,
130+
surface = list(show = TRUE, count = 4, fill = 0.8, pattern = 'odd'),
131+
caps = list(
132+
x = list(show = TRUE),
133+
y = list(show = TRUE),
134+
z = list(show = TRUE)
135+
)
136+
) %>%
137+
layout(
138+
margin=list(t = 0, l = 0, b = 0),
139+
scene=list(
140+
camera=list(
141+
eye=list(
142+
x = 1.86,
143+
y = 0.61,
144+
z = 0.98
145+
)
146+
)
147+
)
148+
)
149+
150+
# Create a shareable link to your chart
151+
# Set up API credentials: https://plot.ly/r/getting-started
152+
chart_link = api_create(p, filename="multiple-isosurface-caps")
153+
chart_link
154+
```
155+
156+
<iframe src="https://plot.ly/~RPlotBot/5643.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
157+
158+
159+
#### Reference
160+
161+
See our [reference page](https://plot.ly/r/reference/) for more information and chart attribute options!.

0 commit comments

Comments
 (0)