【发布时间】:2021-03-19 18:12:06
【问题描述】:
你能告诉我为什么fig.update_yaxes(title=dict(text="$\text{This is a test:} \sqrt{2^4}$")在下面的代码中不起作用
import plotly.express as px
fig = px.bar(df, x=["Apples", "Oranges"], y=[10,20], color=["Here", "There"],
labels=dict(x="Fruit", y="Amount", color="Place")
)
fig.update_yaxes(title=dict(text="$\text{This is a test:} \sqrt{2^4}$", font_size=16)
)
fig.show()
给予
【问题讨论】:
-
您使用的是什么浏览器。我注意到 Firefox 也有同样的问题,但在 Chrome 中一切似乎都运行良好。顺便说一句,请注意您没有在 Python 字符串中转义反斜杠。我建议使用
text=r'$\text{...} \sqrt{...}'或转义反斜杠 -text='\\text{...} \\sqrt{...}' -
是的 Firefox。不是 Safari 的问题。从未尝试过 Chrome(但请参阅下面的 vestland 答案)。