quarto-dev / quarto-dev/quarto-cli
Math in Plotly Figure Labels are not rendering using Quarto provided Mathjax
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
I'm writing a report using Jupyter notebook in VSCode and I'm enable to use math expressions in figure labels while writing math in markdown too!
The output I'm trying to generate is an HTML file.
Here is my observations:
- I need to add a MathJax library to be able to show math properly in plotly figure labels.
- This works well (labels show correctly and figure maintain interactivity) as long as I don't add math in markdown.
- Once I add math in markdown the labels disappear and figure loses interactivity.
Here is a MRE reproducing the issue:
---
format:
html:
execute: true
jupyter: python3
---
```{python}
import plotly.express as px
from IPython.display import display, HTML
display(HTML(
'<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-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$',
)
fig.show()
```
Math in Markdown:
$$x$$
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Jupyter/Quarto MRE and inspecting its generated HTML output, especially the interaction between MathJax, the Plotly figure, and the markdown equation. Done means figure labels render with math, markdown math also renders, and the Plotly figure remains interactive without requiring an incompatible workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, plotly, python, vscode
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100