繁体   English   中英

plotly 中 y 轴标题中的 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()

在此处输入图像描述

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

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

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM