绘图中 y 轴标题中的乳胶不起作用

问题描述 投票:0回答:2

你能告诉我为什么

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

给予

python latex plotly yaxis
2个回答
1
投票

要确定为什么它对你不起作用,我必须知道:

  1. 你的
    plotly version
    ,和
  2. 您如何展示自己的身材 (
    JupyterLab?
    ),以及
  3. 是否有
    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:谷歌浏览器

事实证明,这个问题可能与您运行的浏览器有关。我目前正在运行 Microsoft Edge。但这里是使用 Chrome 的相同代码和图形,没有标题


0
投票

安装 jupyter-server-mathjax 对我有用

© www.soinside.com 2019 - 2024. All rights reserved.