Static Vertical dashed lines in Dash

Hi All,

I am working on a dash based app, where I have 2 subplots one below the other, in this I want to add a dashed vertical lines based on some conditions in the dataframe. Something like the uploaded snip please.

Bit idea on this would be helpful.



Hi Thanks for your reply,

I have plotted subplots using the below code - unable to understand how to access shapes for each plot to insert lines on both the subplots.

fig =,cols=1,shared_xaxes=False)
    fig['layout']['margin']={'l': 80, 'r': 0, 't': 50, 'b': 80}
    fig['layout']['title']= ccypair[0:3]+'/'+ccypair[3:6]+": Flow Recap"
    fig['layout']['yaxis1'].update(title=ccypair[0:3]+'/'+ccypair[3:6] + " rate"),
    fig['layout']['yaxis2'].update(title="Cumulative " + ccypair[0:3]+'/'+ccypair[3:6] + " flow, USD Equivalent")

how can I use this in my code with subplots.

 'shapes': [
        # Line Vertical
            'type': 'line',
            'x0': 1,
            'y0': 0,
            'x1': 1,
            'y1': 2,
            'line': {
                'color': 'rgb(55, 128, 191)',
                'width': 3,

fig['layout']['shapes'] = [{'type': 'line', ...}]

Great thanks for your help, worked perfect so far. One more question on this though, I added the shapes, but it adds only to the top subplot, if you can help on for 2nd subplot will be great.

Many many thanks again.


Please help on this? I am unable to set shapes to 2nd subplot.

Figured this out using xref & yref to x1/x2 & y1/y2

Thanks v much for help

1 Like

Hi, I have a long legend to plot on the same subplot, which i want to place into multiple lines using line break using “\n”, but when i insert it in the string it straight away places \n in between rather than breaking into lines. Can you help please? I am not able to find any way to fix this?

Could you create a new forum issue about this?

“br” inside “< >” worked fine for the legends. Thanks for the help.