Skip to content

make_subplots + hrect rendering bug #6362

@DataScienceIsCool

Description

@DataScienceIsCool

I have already posted this here: Original Post
And there I was told to open an issue here since plotly.js is responsible for this behaviour.

So I have a Jupyter Notebook Cell as follows:

import pandas as pd
import numpy as np
from plotly.subplots import make_subplots
import plotly.graph_objects as go

df = pd.DataFrame(np.random.randint(500,4000,size=(257, 16)), columns=list('ABCDEFGHIJKLMNOP'))

plot_rows=4
plot_cols=4
fig6 = make_subplots(rows=plot_rows, cols=plot_cols, subplot_titles=df.columns)
fig6.update_xaxes(visible=False)
fig6.update_yaxes(range=[0, 6000])

# add traces
for i in range(1, plot_rows + 1):
    for j in range(1, plot_cols + 1):
        k =(i-1)*plot_cols+j-1
        fig6.add_trace(go.Scatter(x=df.index, y=df[df.columns[k]].values,
                                 name = df.columns[k],
                                 mode = 'lines'),
                     row=i,
                     col=j)
fig6.add_hrect(y0=0, y1=1000, line_width=0, fillcolor="red", opacity=0.25, row="all", col="all")
fig6.add_hrect(y0=3000, y1=6000, line_width=0, fillcolor="red", opacity=0.25, row="all", col="all")        
fig6.update_layout(height=650)

Result is a scatter plot with hrects as threshold area.
However in the “J” (10th index) plot, when I zoom into the plot (or use the y-axis slider) the hrect leaks into the other plots:
image

For comparison plot “K” behaves correctly and clips the red area.
I can only ever reproduce this behaviour for the 10th subplot no matter how they are arranged row- and column-wise.

Tested on Jupyter Notebook with MS Edge and VSCode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions