Skip to content

Commit 38559dd

Browse files
authored
3d surface example (#1974)
1 parent 1f71115 commit 38559dd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/python/3d-surface-plots.md

+21
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ 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+
import pandas as pd
62+
import numpy as np
63+
# Read data from a csv
64+
z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')
65+
z = z_data.values
66+
sh_0, sh_1 = z.shape
67+
x, y = np.linspace(0, 1, sh_0), np.linspace(0, 1, sh_1)
68+
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
69+
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
70+
width=500, height=500,
71+
margin=dict(l=65, r=50, b=65, t=90))
72+
fig.show()
73+
```
74+
75+
5576
#### Surface Plot With Contours
5677

5778

0 commit comments

Comments
 (0)