首页 > 解决方案 > 这是出现在我的绘图图中的趋势线吗?

问题描述

如果我的代码看起来很糟糕,我对这一切真的很陌生,所以提前道歉。

我正在尝试绘制一个系列,每个“阶段”相互重叠(x 是分钟)。如果我单独绘制它们,它们看起来会找到,但是一旦我选择了多个阶段,就会在末尾出现一条添加线。不完全确定这是什么。

第 1 阶段本身

第 2 阶段本身

第 1 阶段和第 2 阶段重叠

我正在使用的代码是;

dff.sort_values('Time')
# Create figure with secondary y-axis
fig = make_subplots(
    specs=[[{"secondary_y": True}]])

# Add lines
trace1 = go.Scatter(x=dff['TimeLapse'],
                    y=dff['TPRate'],
                    name='TP',
                    mode='lines',
                    yaxis='y1')
trace2 = go.Scatter(x=dff['TimeLapse'],
                    y=dff['WHSLRRateusethis'],
                    name='SLR',
                    mode='lines',
                    yaxis='y2')
data = [trace2]

#LAYOUT of your graph

layout = go.Layout(  legend=dict(
                            x=1.1,
                            y=.2,
                            traceorder="normal"),

                   autosize=False,
                   width=1200,
                   height=400,
                   title='Graphs',
                   xaxis=dict(
                       title='Time Lapse',
                       range=[0,60],
                       rangeslider=dict(
                           autorange=True)
                   ),
                   yaxis2=dict(title='SLR+Annulus',
                               overlaying='y',
                               side='left',
                               range=[0,50])

                   font=dict(
                       family="Times New Roman",
                       size=12)

感谢任何能够提供帮助的人!

链接到原始数据 - https://raw.githubusercontent.com/chooseanothername/code/main/stack_sample.csv

标签: plotlyplotly-dash

解决方案


推荐阅读