Plotly: how to make an unbounded vertical line in a subplot?

后端 未结 2 593
太阳男子
太阳男子 2021-01-13 04:08

The goal is to get vertical infinite lines in every subplot, at x=1. In this example, I\'ll just try a single plotly shape of type=\"line\" in the first row, first column

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 04:49

    add_vline/add_hline methods were added in 4.12.0 for vertical and horizontal lines. Similar for other shapes too. See https://plotly.com/python/horizontal-vertical-shapes/. An example from those docs:

    import plotly.express as px
    
    df = px.data.iris()
    fig = px.scatter(df, x="petal_length", y="petal_width")
    fig.add_hline(y=0.9)
    fig.add_vrect(x0=0.9, x1=2)
    fig.show()
    

提交回复
热议问题