You can add shapes to your plotly layout. Shapes can include lines or rectangles. They can also be made unbounded by drawing them relative to the plotting area rather than a particular axis. Have a look through the examples in the plotly shapes docs.
layout = {
'title': "My Chart",
'shapes': [
{ # Unbounded line at x = 4
'type': 'line',
# x-reference is assigned to the x-values
'xref': 'x',
# y-reference is assigned to the plot paper [0,1]
'yref': 'paper',
'x0': 4,
'y0': 0,
'x1': 4,
'y1': 1,
'line': {
'color': 'rgb(55, 128, 191)',
'width': 3,
}
},
{ # Unbounded span at 6 <= x <= 8
'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': 6,
'y0': 0,
'x1': 8,
'y1': 1,
'fillcolor': '#d3d3d3',
'opacity': 0.2,
'line': {
'width': 0,
}
}
],
}