✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Can i add a straigh line to a plotly surface plot?

Hello, i am trying to draw straight lines to a plotly surface plot( on a given x,y coordinate and then all the way up the z coordinate, like a axhline/ayhline… i guess a zhline in matplotlib)

i am new to plotly and i am getting completely lost.

take this example:
import plotly.graph_objects as go

import pandas as pd

z_data =pd.read_csv(‘https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv’)

fig = go.Figure(data=[go.Surface(z=z_data.values)])

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


i want a straight line from x = 10, y = 10 and from z i guess from 0 to 350

thank you


Yes you can add a new trace that defines a line:

fig.add_scatter3d(x=[10,10], y=[10,10], z= [0,350], mode='lines', line_width=6, line_color='black')