From d6fcc016529f610128d2994748d89fb2eac91afb Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Tue, 12 Nov 2019 16:33:29 -0500 Subject: [PATCH 1/2] added 3d surface example --- python/3d-surface-plots.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/python/3d-surface-plots.md b/python/3d-surface-plots.md index cd720c939..169220c07 100644 --- a/python/3d-surface-plots.md +++ b/python/3d-surface-plots.md @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.7.3 plotly: description: How to make 3D-surface plots in Python display_as: 3d_charts @@ -52,6 +52,30 @@ fig.update_layout(title='Mt Bruno Elevation', autosize=False, fig.show() ``` +### Passing x and y data to 3D Surface Plot + +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`. + +```python +import plotly.graph_objects as go + +import pandas as pd + +# Read data from a csv +z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv') +z = z_data.values +sh_0, sh_1 = z.shape +x, y = np.linspace(0, 1, sh_0), np.linspace(0, 1, sh_1) + +fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)]) + +fig.update_layout(title='Mt Bruno Elevation', autosize=False, + width=500, height=500, + margin=dict(l=65, r=50, b=65, t=90)) + +fig.show() +``` + #### Surface Plot With Contours From c656d2fd2a433232b1d5a23c80ec5731a9c6080a Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Tue, 12 Nov 2019 16:42:19 -0500 Subject: [PATCH 2/2] import bug --- python/3d-surface-plots.md | 1 + 1 file changed, 1 insertion(+) diff --git a/python/3d-surface-plots.md b/python/3d-surface-plots.md index 169220c07..50f327d04 100644 --- a/python/3d-surface-plots.md +++ b/python/3d-surface-plots.md @@ -60,6 +60,7 @@ If you do not specify `x` and `y` coordinates, integer indices are used for the import plotly.graph_objects as go import pandas as pd +import numpy as np # Read data from a csv z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')