October 22, 2021

Yummy 3D plots

Very nice interactive 3D plots with Plotly.

import plotly.graph_objects as go
import numpy as np
import pandas as pd

# Read data from a csv
Z = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv').values

# Actually not necessary to provide X and Y...
X = np.linspace(0, 1000, Z.shape[0])
Y = np.linspace(0, 1000, Z.shape[1])

fig = go.Figure(data=[go.Surface(x=X, y=Y, z=Z)])

fig.update_layout(title='Mt Bruno Elevation', autosize=False,
                  width=500, height=500,
                  margin=dict(l=65, r=50, b=65, t=90))


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.