-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure does not display LaTeX title #1740
Comments
Related to outstanding issues in #1243 (comment)
|
I would like to solve this; any kind of initial help regarding at which code to look would be helpful. I briefly inspected the console and found MathJax in the |
@LunarLanding
or you can avoid using dicts, as follows:
|
Latex with a dict does not work: import plotly.graph_objects as go
fig = go.Figure(
data=go.Bar(y=[2,3,1]),
layout={'title': {'text':'$a_b$','x':.5}})
fig.show(config={'responsive':True}); Without latex, using title directly works, without latex (not the issue being discussed): import plotly.graph_objects as go
fig = go.Figure(
data=go.Bar(y=[2,3,1]),
layout={'title': 'a'})
fig.show(config={'responsive':True}); |
Thanks. This issue is specific to JupyterLab then; which is also what the original poster reported. |
I can replicate the JupyterLab problem on my end also. The issue is likely to be within the interaction between the way |
I'll add that the LaTeX information is not lost: rendering the same figure in a Dash app or in another context than JLab works (e.g. exporting a notebook to HTML), and in a pinch you can render it in JLab if you have Kaleido installed with |
I think the issue is that Mathjax is not by default present in the global namespace anymore, the same as in jupyter-widgets/ipywidgets#2253 which one extension worked around like this vidartf/phoila@2b7ddf0 . If I run this before running the plotly cell, latex is rendered correctly. from IPython.display import display,HTML
display(HTML("""
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=config=TeX-AMS-MML_SVG">
</script>
""")) Having it render without a kernel/rerunning cells is WIP, this error shows up on the browser console and on the output cell there's a text only
If instead of a FigureWidget I use a Figure, the figure renders on opening with jupyterlab. If I reload the page, MathJax dissapears from the global namespace and latex is not rendered. At this point, the workaround above + using only go.Figure and not FigureWidgets gets almost to right place.
Additionally, regarding size of the notebook, FigureWidget packs 3.6MB for ploty.js, while Figure refers to the jupyterlab extension. If I specify If I export the notebook to html, FigureWidget renders properly, Figure does not: only the static preview is shown, while FigureWidget updates to the dynamic javascript. Dealing with rather simple Latex I found a dependency on browser plotly/plotly.js#5374 (comment) ."Why do you use Edge? Plotly edge-case". This was on: Firefox 93.0, Jupyterlab 3.2.0, plotly 5.3.1, python 3.9.7.
|
I found a solution that worked for me in the help documentation, changing the default renderer. I had the issue on multiple browsers. (https://plotly.com/python/renderers/)
Renderers configuration
|
There is an issue with rendering LaTeX titles in JupyterLab:
Does not actually display the titles:

And this is strange as earlier today it did work fine.
I have encountered other anomalies in JupyterLab, such as after restarting the session, one image elongates and stays like that.
Does not happen every time though.
Details
Plotly version: 4.0.0
Ubuntu 18.04.2
Here it is:

Sometimes it elongates and stays like that:
UPDATE 1:
I've just updated to 4.1.0 and now the LaTeX titles are displayed. But, the mentioned anomaly is still there.
UPDATE 2:
I have opened the notebook today again and the title disappears.
If it is of any help. here is what is displayed in the terminal:

The text was updated successfully, but these errors were encountered: