Skip to content

Latex not working in jupyter notebook v7. #4336

Closed
@pfebrer

Description

@pfebrer

I recently upgraded to jupyter notebook v7 and I noticed that some plotly plots that previously rendered flawlessly now fail to render. I get the following output:

Screenshot from 2023-08-22 12-27-21

After some exploration I found out that it comes from an error using MathJax in jupyterlab-plotly. It tries to access MathJax.config.startup.output, but MathJax.config.startup is undefined.

It is very easy to reproduce this error:

  • Create a new python environment (I tried with python 3.8).
  • pip install jupyter plotly
  • Open a jupyter notebook with jupyter notebook.
  • Run a cell with the following code:
from plotly.graph_objects import Figure

Figure().update_layout(title="$Title$")

Activity

pfebrer

pfebrer commented on Aug 22, 2023

@pfebrer
Author

Ok, I installed the jupyterlab-plotly extension with jupyter labextension install plotlywidget and it works, so I guess this will be fixed in the next python package release (?)

pfebrer

pfebrer commented on Aug 22, 2023

@pfebrer
Author

No, sorry it also doesn't work, the previous code snippet just literally shows "$Title$" as a title, but prepending the string with 'r' makes the issue show again:

from plotly.graph_objects import Figure

Figure().update_layout(title=r"$Title$")
zhimin-z

zhimin-z commented on Aug 27, 2023

@zhimin-z

Hi, I faced the same issue, any update?

pfebrer

pfebrer commented on Aug 27, 2023

@pfebrer
Author

No, I still need some solution for this 😅

newville

newville commented on Nov 14, 2023

@newville
Contributor

@zhimin-z @pfebrer I've been seeing this issue for a while too. Is there any understanding of the cause and what might be done to fix it?

zhimin-z

zhimin-z commented on Nov 14, 2023

@zhimin-z

Yeah, still there... @newville
image

newville

newville commented on Nov 14, 2023

@newville
Contributor

@zhimin-z Yes, the problem still exists. Is there any understanding of the cause of the problem? Has anyone investigated what is going on in the code? I'm afraid this is a bit outside of my area of expertise.

zhimin-z

zhimin-z commented on Nov 14, 2023

@zhimin-z

I have no idea...anyone who is in charge of latex functionality in this repo?

pfebrer

pfebrer commented on Nov 14, 2023

@pfebrer
Author

I'm tagging @alexcjohnson since he seems to be the last to have committed something to jupyterlab-plotly other than version changes :)

It looks like this is an easy fix that just needs an update to use the latest MathJax version, or somehow forcing jupyterlab to use an oldest one, I don't know if that's possible.

newville

newville commented on Nov 20, 2023

@newville
Contributor

@pfebrer @alexcjohnson Thanks for looking into this. Is there anything the rest of us can do to help further troubleshoot or fix this issue? I'll admit that I do not have a deep understanding of how plotply.py and plotly.js interact or which version of mathjax
is actually being used.

pfebrer

pfebrer commented on Nov 22, 2023

@pfebrer
Author

I don't know, everything I know is that jupyterlab uses MathJax 3.2 and plotly's docs use 2.7, but in principle version 3 should work as well according to plotly/plotly.js#6073

I don't even know how to modify jupyterlab-plotly and use a modified version of the extension. I have tried to pip install -e . the plotly repo to play a little bit with it but then jupyter doesn't render anything.

newville

newville commented on Nov 26, 2023

@newville
Contributor

@pfebrer Thanks, sorry to be dense, but what precisely would one have to do to make it work? Could that be folded into the plotly-py code?

The issue is kind of 3 months old, and it seems that there has been no explanation or acknowledgment of this issue.
But, I don't really know what that means. Maybe the solution is obvious to someone?

55 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1needed for current cyclebugsomething brokensev-2serious problem

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @newville@gvwilson@alexcjohnson@LunarLanding@marthacryan

    Issue actions

      Latex not working in jupyter notebook v7. · Issue #4336 · plotly/plotly.py