你能告诉我为什么以下代码中的 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()
提供
text=r'$\text{...} \sqrt{...}'
或转义反斜杠-text='\\text{...} \\sqrt{...}'
。 - Andrew Slabko