Search code examples
pythonplotlyplotly-python

Plotly does not display LaTeX formulas after implementing $...$


This is an example from plotly website: Latex in Python, and different from the example, my code just won't show the rendered formula:

import plotly.express as px

fig = px.line(x=[1, 2, 3, 4], y=[1, 4, 9, 16], title=r'$\alpha_{1c} = 352 \pm 11 \text{ km s}^{-1}$')
fig.update_layout(
    xaxis_title=r'$\sqrt{(n_\text{c}(t|{T_\text{early}}))}$',
    yaxis_title=r'$d, r \text{ (solar radius)}$'
)
fig.show()

My result: enter image description here


Solution

  • There was a workaround posted in the plotly git issues: https://github.com/microsoft/vscode-jupyter/issues/8131#issuecomment-1589961116

    This works for me in Jupyter-lab