Davide-sd / sympy-plot-backends

An improved plotting module for SymPy
BSD 3-Clause "New" or "Revised" License
42 stars 9 forks source link

Incorrect symbol names displayed in example plot #16

Closed michelececcacci closed 1 year ago

michelececcacci commented 1 year ago

Python 3.9.13 Spb version: 1.6.6 Sympy version: 1.10.1 As you can see in the image i uploaded, In the following example (second in the verifying installation folder) every name has a $ character prepended and one appended. To reproduce, just paste this in an empty python repl interpreter:

from sympy import *
from spb import *
x, a, b, c = symbols("x, a, b, c")
plot(
    (cos(a * x + b) * exp(-c * x), "oscillator"),
    (exp(-c * x), "upper limit", {"line_dash": "dotted"}),
    (-exp(-c * x), "lower limit", {"line_dash": "dotted"}),
    (x, 0, 2 * pi),
    params={
        a: (1, 0, 10),     # frequency
        b: (0, 0, 2 * pi), # phase
        c: (0.25, 0, 1)    # damping
    },
    ylim=(-1.25, 1.25),
    backend=BB,
    servable=True
)

image

Davide-sd commented 1 year ago

Yep, known behavior caused by Bokeh version < 3 which didn't fully supported Latex. Holoviz's Panel uses Bokeh to create widgets. The current version of Panel uses Bokeh 2.4.3. Full Latex support is available in Bokeh 3.0 and up, but Panel still has to catch up. Following Bokeh's doc, once that happens, this line of code should be changed to use double $ wrapper.

michelececcacci commented 1 year ago

Ok, perfect. Thanks for the quick reply!