我在 Python 中生成了以下 Plotly 图表。我已将回归调整为一组有限的点,并得到以下图表:
我想在这些点和调整后的曲线之间画一条垂直线,如下例所示:
我正在使用 Plotlyplotly.graph_objects , pandas来生成这些图表,但我不知道如何绘制它们。这是我正在使用的代码:
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)


