You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/3d-mesh.md
+36-3
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,8 @@ jupyter:
5
5
text_representation:
6
6
extension: .md
7
7
format_name: markdown
8
-
format_version: '1.1'
9
-
jupytext_version: 1.1.1
8
+
format_version: '1.2'
9
+
jupytext_version: 1.3.0
10
10
kernelspec:
11
11
display_name: Python 3
12
12
language: python
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.6.7
23
+
version: 3.7.3
24
24
plotly:
25
25
description: How to make 3D Mesh Plots
26
26
display_as: 3d_charts
@@ -127,5 +127,38 @@ fig = go.Figure(data=[
127
127
fig.show()
128
128
```
129
129
130
+
### Intensity values defined on vertices or cells
131
+
132
+
The `intensitymode` attribute of `go.Mesh3d` can be set to `vertex` (default mode, in which case intensity values are interpolated between values defined on vertices), or to `cell` (value of the whole cell, no interpolation). Note that the `intensity` parameter should have the same length as the number of vertices or cells, depending on the `intensitymode`.
133
+
134
+
Whereas the previous example used the default `intensitymode='vertex'`, we plot here the same mesh with `intensitymode='cell'`.
135
+
136
+
```python
137
+
import plotly.graph_objects as go
138
+
fig = go.Figure(data=[
139
+
go.Mesh3d(
140
+
# 8 vertices of a cube
141
+
x=[0, 0, 1, 1, 0, 0, 1, 1],
142
+
y=[0, 1, 1, 0, 0, 1, 1, 0],
143
+
z=[0, 0, 0, 0, 1, 1, 1, 1],
144
+
colorbar_title='z',
145
+
colorscale=[[0, 'gold'],
146
+
[0.5, 'mediumturquoise'],
147
+
[1, 'magenta']],
148
+
# Intensity of each vertex, which will be interpolated and color-coded
149
+
intensity= np.linspace(0, 1, 12, endpoint=True),
150
+
intensitymode='cell',
151
+
# i, j and k give the vertices of triangles
152
+
i= [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],
153
+
j= [3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
154
+
k= [0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
155
+
name='y',
156
+
showscale=True
157
+
)
158
+
])
159
+
160
+
fig.show()
161
+
```
162
+
130
163
## Reference
131
164
See https://plot.ly/python/reference/#mesh3d for more information and chart attribute options!
0 commit comments