Skip to content

Commit c371a00

Browse files
authoredDec 2, 2019
added 3d surface example (#196)
* added 3d surface example * import bug
1 parent 941ba99 commit c371a00

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed
 

‎python/3d-surface-plots.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.7
23+
version: 3.7.3
2424
plotly:
2525
description: How to make 3D-surface plots in Python
2626
display_as: 3d_charts
@@ -52,6 +52,31 @@ fig.update_layout(title='Mt Bruno Elevation', autosize=False,
5252
fig.show()
5353
```
5454

55+
### Passing x and y data to 3D Surface Plot
56+
57+
If you do not specify `x` and `y` coordinates, integer indices are used for the `x` and `y` axis. You can also pass `x` and `y` values to `go.Surface`.
58+
59+
```python
60+
import plotly.graph_objects as go
61+
62+
import pandas as pd
63+
import numpy as np
64+
65+
# Read data from a csv
66+
z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')
67+
z = z_data.values
68+
sh_0, sh_1 = z.shape
69+
x, y = np.linspace(0, 1, sh_0), np.linspace(0, 1, sh_1)
70+
71+
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
72+
73+
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
74+
width=500, height=500,
75+
margin=dict(l=65, r=50, b=65, t=90))
76+
77+
fig.show()
78+
```
79+
5580
#### Surface Plot With Contours
5681

5782

0 commit comments

Comments
 (0)
Failed to load comments.