-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
plotly 4.14.3
I cannot make a h/v line 'sticky' relatively to the subplots.
'paper' property is respected only when the line is drawn for the whole plot but not for the individual subplots.
See those two lines:
fig.add_shape(line, row=1, col=2)
import plotly.graph_objects as go
import json
import plotly
from io import StringIO
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(
cols=4,
rows=2,
# share only in rows:
#shared_yaxes="rows",
#subplot_titles=['first','', 'second', 'third'],
)
a_line = dict(color='rgb(1, 4, 4)')
b_line = dict(color='rgb(44, 160, 101)')
c_line = dict(color='rgb(222, 160, 222)')
# facet 1
fig.add_trace(go.Scatter(y=[1, 1], x=[1,1], legendgroup="A 1", name="A",line=a_line, showlegend = False),1, 1)
fig.add_trace(go.Scatter(y=[1, 1], x=[1,1], legendgroup="A 1", name="A",line=a_line, showlegend = False),1, 2)
fig.add_trace(go.Scatter(y=[1, 1], x=[1,1], legendgroup="A 1", name="A",line=a_line, showlegend = False),1, 3)
# facet 1
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B",line=b_line, showlegend = True),1, 2)
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B",line=b_line, showlegend = False),1, 2)
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B",line=b_line, showlegend = False),2, 2)
# facet 2
fig.add_trace(go.Scatter(y=[1, 1], x=[1,1], legendgroup="A 1", name="A 1",line=a_line, showlegend = False),2, 2)
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B 1",line=b_line, showlegend = False),2, 2)
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B",line=b_line, showlegend = False),2, 3)
fig.add_trace(go.Scatter(y=[2, 2], x=[2,2], legendgroup="B 1", name="B",line=b_line, showlegend = False),2, 3)
#fig.add_trace(go.Scatter(y=[3, 3], x=[3,3], legendgroup="C", name="C",line=c_line, showlegend = False),row=3, col=3)
line = dict(type="line", xref="x", x0=1.5, x1=1.5, yref="paper", y0=0, y1=1)
# fig.add_shape(shape, row=1, col=2)
# globally it works:
fig.update_layout(shapes=[line])
# for a specific subplot 'paper' is ignored :
fig.add_shape(line, row=1, col=2)
fig.show()
Might be related issue:
Metadata
Metadata
Assignees
Labels
No labels

