79400412

Date: 2025-01-30 15:43:48
Score: 0.5
Natty:
Report link

First lets use a newer version of MathJax, if possible to iron out any old bugs. See the suggested way to setup MathJax via HTML here.

I also found I had to set automargin to true so the Y axis didn't get cut off, but you may not need this.

So our final .qmd file looks something like this:

---
format:
  html:
    embed-resources: true
---

```{python}
import plotly.express as px
from IPython.display import HTML, display

display(
    HTML(
        # NOTE: See new HTML code below
        '<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-svg.js"></script>'
    )
)

fig = px.line(
    x=[0, 1, 2, 3, 4],
    y=[1, 2, 4, 8, 16],
)
fig.update_layout(yaxis_title="$2^x$", xaxis_title="$x$")
# NOTE: See new automargin option below
fig.update_yaxes(automargin=True)
fig.show()
```

Results in: enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Quinton.Quagliano