2021年4月29日星期四

Plotly add_hline() doesn't work with simple_white template

I was attempting to add a horizontal line to a Plotly graph using Plotly's add_hline(). It works perfectly fine so long as I do not use the simple_white template. The MWE is here:

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()  

Without the template='simple_white' line, the add_hline() works as expected. With that template though, and with no other changes, the plot is the same but without the horizontal line.

enter image description here enter image description here

https://stackoverflow.com/questions/67327670/plotly-add-hline-doesnt-work-with-simple-white-template April 30, 2021 at 11:03AM

没有评论:

发表评论