【发布时间】:2021-07-23 10:18:45
【问题描述】:
我试图使用 Plotly 的 add_hline() 向 Plotly 图形添加一条水平线。只要我不使用 simple_white 模板,它就可以正常工作。 MWE 在这里:
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, line_dash='dash', line_color='Red')
fig.update_layout(width=400, height=400,
# template='simple_white'
)
fig.show()
如果没有 template='simple_white' 行,add_hline() 将按预期工作。虽然使用该模板,并且没有其他更改,但情节是相同的,但没有水平线。
【问题讨论】:
标签: plotly