I have the following code cell in a jupyter-notebook:
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
x = 0
for i in range(1, plot_rows + 1):
for j in range(1, plot_cols + 1):
fig6.add_trace(go.Scatter(x=df.index, y=df[df.columns[x]].values,
name = df.columns[x],
mode = 'lines'),
row=i,
col=j)
fig6.add_hrect(y0=0, y1=1000, line_width=0, fillcolor="red", opacity=0.25, row=i, col=j)
fig6.add_hrect(y0=3000, y1=6000, line_width=0, fillcolor="red", opacity=0.25, row=i, col=j)
x=x+1
fig6.show()
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:
For comparison plot βKβ behaves correctly and clips the red are.
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.
Can someone confirm this bug or tell me that Iβm missing something?