Below i can code for two vertical rectangle shapes.
How it should be modified in order to get a two horizontal rectangle shapes.
I have tried my best, but i canβt figure it out.
import plotly.graph_objects as go
fig = go.Figure()
Add scatter trace for line
fig.add_trace(go.Scatter(
x=[β2015-02-01β, β2015-02-02β, β2015-02-03β, β2015-02-04β, β2015-02-05β,
β2015-02-06β, β2015-02-07β, β2015-02-08β, β2015-02-09β, β2015-02-10β,
β2015-02-11β, β2015-02-12β, β2015-02-13β, β2015-02-14β, β2015-02-15β,
β2015-02-16β, β2015-02-17β, β2015-02-18β, β2015-02-19β, β2015-02-20β,
β2015-02-21β, β2015-02-22β, β2015-02-23β, β2015-02-24β, β2015-02-25β,
β2015-02-26β, β2015-02-27β, β2015-02-28β],
y=[-14, -17, -8, -4, -7, -10, -12, -14, -12, -7, -11, -7, -18, -14, -14,
-16, -13, -7, -8, -14, -8, -3, -9, -9, -4, -13, -9, -6],
mode=βlinesβ,
name=βtemperatureβ
))Add shape regions
fig.update_layout(
shapes=[
# 1st highlight during Feb 4 - Feb 6
dict(
type=βrectβ,
# x-reference is assigned to the x-values
xref=βxβ,
# y-reference is assigned to the plot paper [0,1]
yref=βpaperβ,
x0=β2015-02-04β,
y0=0,
x1=β2015-02-06β,
y1=1,
fillcolor=βLightSalmonβ,
opacity=0.5,
layer=βbelowβ,
line_width=0,
),
# 2nd highlight during Feb 20 - Feb 23
dict(
type=βrectβ,
xref=βxβ,
yref=βpaperβ,
x0=β2015-02-20β,
y0=0,
x1=β2015-02-22β,
y1=1,
fillcolor=βLightSalmonβ,
opacity=0.5,
layer=βbelowβ,
line_width=0,
)
]
)fig.show()