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

时间:2021-03-19 18:12:06

标签: python latex plotly yaxis

你能告诉我为什么 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()

给予

enter image description here

1 个答案:

答案 0 :(得分:1)

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

  1. 您的plotly version,以及
  2. 您如何显示您的图 (JupyterLab?),以及
  3. 是否有 enough space for your title 用于输出图形。

因为它在我这边工作正常:

enter image description here

我正在 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 的相同代码和图,没有标题

enter image description here