I'd like to stack a plotly.express
line plot atop a filled rectangle from graph_objects
. Creating the figure with px.line
and then adding the filled rectangle makes the rectangle show up above the line (notebook).
import plotly.express as px
import plotly.graph_objects as go
fig = px.line(x=[0, 2, 4], y=[1, 2, 3])
fig.add_trace(go.Scatter(
x=[1, 1, 3, 3, 1],
y=[0, 5, 5, 0, 0],
fill="toself")
)
fig.show()
How can I get the line above the rectangle?