I've generated the following Plotly chart in Python. I've adjusted a regression to a finite set of points, and got the following chart:
I want to draw a vertical line between those points and the adjusted curve, like in the example below:
I'm using a Plotly plotly.graph_objects , pandas
to generate those graphs and I have no idea on how to draw them. This is the code that I'm using:
import pandas as pd
import plotly.graph_objects as go
for point, curve in zip(points, curves):
point_plot = go.Scatter(x=df['Duration'],
y=df[point],
name=point,
# text=df['Nome'],
mode='markers+text',
line_color=COLOR_CODE[point],
textposition='top center')
line_plot = go.Scatter(x=df['Duration'],
y=df[curve],
name='',
line_color=COLOR_CODE[point],
mode='lines')
# XXX: this don't solve the problem but it's what I could think of for now
to_bar = df[points].diff(axis=1).copy()
to_bar['Nome'] = df['Nome']
bar_plot = go.Bar(x=to_bar['Nome'], y=to_bar[point], name='', marker_color=COLOR_CODE[point])
fig.add_trace(line_plot, row=1, col=1)
fig.add_trace(point_plot, row=1, col=1)
fig.add_trace(bar_plot, row=2, col=1)