Is it possible to add latex in legend?

Hi all,
I’m building a plot and need to add the formula for each component as part of the legend. As of now, the best that I could do is to write the formula in text format. It would be really nice if I could write them in latex format though. I have tried so many things, none seems to work. Any tip is appreciated.

Here’s a working example:

import holoviews as hv
import numpy as np
import panel as pn

pn.extension('katex')

X_VALUES = np.arange(-40, 11, 0.5).round(1)

def calc_points(
    coefficient: int, x: np.array = X_VALUES
) -> list:
    return np.column_stack(
        (
            x,
            (coefficient * 10 ** (x / 40 + 2)).round(1),
        )
    ).tolist()

def create_curve(coefficient: int):
    label = f"Distance(m)={str(coefficient)} * 2 ^ ((X+20)/(40*log_10(2)))"
    points = calc_points(coefficient=coefficient, x=X_VALUES)
    curve = hv.Curve(points,label=label,group="curve").opts(width=1000, show_legend=True)
    return curve

curve1 = create_curve(2)
curve2 = create_curve(3)

pn.panel((curve1 * curve2).opts(title="Curves"))

I tihnk it’s related to:

As an alternative you could probably create labels in the corresponding colors? Creating LaTeX labels — Bokeh 2.4.1 Documentation

Cool! I’ll give it a try. thanx

Just tryin to run the example from the link, I get an error.

I have had a lot of success running messy error messages through chatGPT:
seems a lot of people have asked questions about errors! :wink: