Ghost lines in go.Scatter

Hello

I found a really special behaviour. If i start plotting my stuff in some of the Subplots i can move them around in the html view and some Ghost lines with no value are following.

Normal chart

This is the moved chart

My code looks as followed:

def plot_algorithm2(distance01_df, distance23_df, distance0123_df, diff_distance_df, distance_filtered_df,
                    meas_description: str):
    pathToSaveHTML = 'figures/'
    pathToSavePNG = 'figures/'
    fig = sp.make_subplots(rows=2, cols=2)

    # add traces to subplots
    trace_dist01 = go.Scatter(x=distance01_df['frame [#]'], y=distance01_df['Distance [mm]'], name='Distance 01')
    trace_dist23 = go.Scatter(x=distance23_df['frame [#]'], y=distance23_df['Distance [mm]'], name='Distance 23')
    trace_dist0123 = go.Scatter(x=distance0123_df['frame [#]'], y=distance0123_df['Distance [mm]'],
                                name='Distance 0123')
    trace_dist_diff = go.Scatter(x=diff_distance_df['frame [#]'], y=diff_distance_df['Distance [mm]'],
                                 name='Distance diff')
    trace_dist_filtered = go.Scatter(x=distance_filtered_df['frame [#]'], y=distance_filtered_df['Distance [mm]'],
                                     name='Distance filtered')

    fig.add_trace(trace_dist01, row=1, col=1)
    fig.add_trace(trace_dist23, row=1, col=1)
    fig.add_trace(trace_dist_filtered, row=2, col=2)
    fig.add_trace(trace_dist0123, row=2, col=1)
    fig.add_trace(trace_dist_diff, row=1, col=2)

    fig.add_hrect(y0=DISTANCE_FILTERED_MIN, y1=DISTANCE_FILTERED_MAX, row=1, col=2, fillcolor="red", opacity=0.2)

    fig.update_xaxes(title_text="Frames [#]", row=1, col=1)
    fig.update_xaxes(title_text="Frames [#]", row=1, col=2)
    fig.update_xaxes(title_text="Frames [#]", row=2, col=1)
    fig.update_xaxes(title_text="Frames [#]", row=2, col=2)

    # Update yaxis properties
    fig.update_yaxes(title_text="Distance [mm]", row=1, col=1)
    fig.update_yaxes(title_text="Distance [mm]", row=1, col=2)
    fig.update_yaxes(title_text="Distance [mm]", row=2, col=1, range=[13700, 14300])
    fig.update_yaxes(title_text="Distance [mm]", row=2, col=2, range=[13700, 14300])

    # set layout
    fig.update_layout(
        title='Algorithm 2: \n' + file_description[meas_description]
    )

    offline.plot(fig, filename=pathToSaveHTML + file_description[meas_description] + '_Algorithm_2.html',
                 auto_open=True)
    plotly.io.write_image(fig, file=pathToSavePNG + file_description[meas_description] + '_Algorithm_2.png', width=1920,
                          height=1080)

A dataframe looks as followed:

def get_df_distance_all_pixels(plot: Plot, distance_data: np.ndarray):
    dist_df = pd.DataFrame()
    dist_df['Distance [mm]'] = distance_data[plot.idx_rows[0]:(plot.idx_rows[-1] + 1),
                               plot.idx_cols[0]:(plot.idx_cols[-1] + 1), :].flatten()
    dist_df['rows'] = np.repeat(plot.idx_rows, plot.len4_cols * plot.len5_frames)
    dist_df['cols'] = np.tile(np.repeat(plot.idx_cols, plot.len5_frames), plot.len3_rows)
    dist_df['frame [#]'] = np.tile(plot.idx_frame, plot.len3_rows * plot.len4_cols)

    return dist_df

hi @Rextorne

Thank you for reporting this.

I think this issue is similar to the #6407 issue. It got fixed with #6429 PR. So if you are using Plotly.js 2.17.1 or higher, it should not happen.

Here’s how you can see what version of Plotly.js you’re using on any plotly graph.

Hello

Thanks for the answer. You are right, I am using Plotly.js v2.16

How can I upgrade this with the python Plotly ?

My python plotly version is 5.11.0

Greetings

Try Plotly 5.12.0 or higher because that includes Plotly.js v2.17.1.