y-axis 标题中的 Latex 无法正常工作
Latex in y-axis title in plotly not working
你能告诉我为什么 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()
给予
要确定为什么它在您这边不起作用,我必须知道:
- 你的
plotly version
,和
- 您如何显示您的身材 (
JupyterLab?
),并且
- 是否有
enough space for your title
你输出图形的地方。
因为它在我这边运行良好:
我在 JupyterLab 运行 Plotly '4.14.3'
。
与您的代码相同:
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()
编辑 1:GoogleChrome
事实证明,这个问题可能与您的 运行 浏览器有关。我现在是 运行 Microsoft Edge。但这里是使用 Chrome 和 无标题:
的相同代码和图形
你能告诉我为什么 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()
给予
要确定为什么它在您这边不起作用,我必须知道:
- 你的
plotly version
,和 - 您如何显示您的身材 (
JupyterLab?
),并且 - 是否有
enough space for your title
你输出图形的地方。
因为它在我这边运行良好:
我在 JupyterLab 运行 Plotly '4.14.3'
。
与您的代码相同:
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()
编辑 1:GoogleChrome
事实证明,这个问题可能与您的 运行 浏览器有关。我现在是 运行 Microsoft Edge。但这里是使用 Chrome 和 无标题:
的相同代码和图形