✊🏿 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!

Retrieving value from scatter plot line

Hi! If i make a scatter plot with a line, is there a way for me to continue this line for n amount of time ( since my x axis is ‘Date’ ) and get the values from this line, that is after all data is plotted.

Don’t know how to phrase this so ask if something was unclear. Thanks in advance!

For this I think it is easier if you use dash live update because plotly by itself does not support continuous plotting.

If you have a Figure object (returned when you call px.scatter() or go.Figure(), you can access the 'data` property to get all the traces in your plot. Each of these traces represent a line.

import plotly.express as px

df = {
    "x": [1,2,3],
    "y": [7,8,9],
}

fig = px.scatter(df, x="x", y="y")
data = fig.data
print(len(data))  # should print 1 because we only have one trace/line

print(data[0]['x'])
# (1 2 3)

print(data[0]['y'])
# (7 8 9)