-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
LaTeX Support for Labels (Title, Axes, Ticks, Colorbar, etc.) #5740
Comments
A couple of observations:
The LaTeX substring issue is known and something we would like to fix, but I don't know if anyone is activately working on it. I should also point out that when I first ran my simple example above I didn't see any LaTeX at all and I was seeing |
Ah, okay, I didn't realize about 1., the documentation is a little confusing because further down the page, there's an example using a substring with div and paragraph widgets. As for reproducing my error (which I think is what you meant), I didn't post a snippet of my code because I can't really share a condensed version. My research involves visualizing unstructured grid climate models (models that use unusual shapes as their grid, quasi-hexagons are shown above) and I use spatialpandas and holoviews.Polygons (and geoviews) that have been rasterized with datashader. Since all of the packages within holoviews are managed separately, my error could be related to holoviews' interaction with a different package that's not obvious within the traceback. |
Yes I can see that the documentation is confusing. There are really two separate implementations of LaTeX in Bokeh. For
I didn't mean any criticism, I just wanted to post a minimal working example of LaTeX in HoloViews to confirm that something works and it is not completely broken. I agree that the error message you saw is not very informative! |
@byquip please open an issue on Bokeh issue tracker if an existing issue do not already exists. from bokeh.io import show, output_notebook
from bokeh.models import CustomJS, RadioButtonGroup
output_notebook()
lab = r"$$\text{Dependency on }R_{core}$$"
rbg = RadioButtonGroup(labels=['Dependency on N', lab],active=1)
show(rbg) |
Hello, I've encountered a similar issue with Latex labels, where they won't even show up. Following @ianthomas23 simple example, I get this: Software versions: |
EDIT: For now, I found the following solution for my needs.
Let me know if it fixed it for everyone else :) @ianthomas23 there appear to be some issues with the logic of enabling mathjax in holoviews for me. I would have expected it to work with something like:
But after poring through the code, the panel import is what fixed things... OLD COMMENT: For some reason (probably performance), mathjax appears to not be added to the templates in the HTML. I saved my plot as a standalone HTML and got this problem. The default template loading list appears to have changed in recent Bokeh versions to:
which does not include mathjax. So I needed to add
Not sure how to make this the default for widgets generated in a notebook though. Any tips? Software versions:
|
The original problem by @cdeciampa, as far as I can see, is already supported or will need work done in Bokeh itself. The second problem by @cdeciampa around The problem by @ @byquip is a Bokeh feature request and is tracked on their issue tracker. The problem described by @wen-jams and @sunilkpai should be fixed by #5904 and will be out in the next release, 1.18. Thank you for the investigation, @sunilkpai. I really, really appreciated it! I think that was all of it and if not please open new issues. |
@hoxbro it seems like the fix in 1.18.0 is only working when running in import holoviews as hv
import panel as pn
hv.extension("bokeh", enable_mathjax=True)
a = hv.Rectangles([[0, 0, 1, 1]]).opts(title=r"$$\alpha \beta$$", xlabel="$$y$$")
pn.panel(a).servable() For example in Jupyterlab with the Panel preview, you can see the LaTeX is rendered in the widget but not inline: The However, saving the plot to HTML shows that mathjax is indeed included: <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-3.3.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.3.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.3.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.3.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.3.0.min.js"></script>
<script type="text/javascript" src="https://cdn.holoviz.org/panel/1.3.0/dist/panel.min.js"></script> The LaTeX labels show up fine in the plot from HTML as well. Software versions:
|
I think this is an upstream issue, as I also see the same problem using Bokeh: bokeh/bokeh#13499 |
Package versions:
As of Bokeh 3.0, LaTeX is now supported, but I don't think it's supported by holoviews yet. Using
r"Upwelling Longwave Flux W$$m^{-2}$$"
doesn't work for the colorbar label:And using that same label but for the title throws a KeyError:
The text was updated successfully, but these errors were encountered: