def mpl_process_lbl(lbl, math=False):
    """
    Process a (plotly-compatible) text label `lbl` to matplotlb text.

    Parameters
    ----------
    lbl : str
        A text label to process.

    math : bool, optional
        Whether math-formatting (latex) should be used.

    Returns
    -------
    str
    """
    if not isinstance(lbl, str):
        lbl = str(lbl)  # just force as a string
    math = math or ('<sup>' in lbl) or ('<sub>' in lbl) or \
        ('_' in lbl) or ('|' in lbl) or (len(lbl) == 1)
    try:
        float(lbl)
        math = True
    except: pass

    l = lbl
    l = l.replace("<i>", "").replace("</i>", "")
    l = l.replace("<sup>", "^{").replace("</sup>", "}")
    l = l.replace("<sub>", "_{").replace("</sub>", "}")
    l = l.replace("<br>", "\n")

    if math:
        l = l.replace("alpha", "\\alpha")
        l = l.replace("beta", "\\beta")
        l = l.replace("sigma", "\\sigma")

    if math or (len(l) == 1): l = "$" + l + "$"
    return l