Sympy returns a print of an expression in Jupyter in mathematical notation. E.g.:
from sympy import symbols
from sympy.plotting import plot
x = symbols("x")
2 + 3 * x**2
However, I can’t include this in a plot title. If I run
exp = 2 + 3 * x**2
plot(exp, title=exp)
it will print the expression in the Python notation: 2 + 3 * x**2
Is there any way to get the mathematical notation shown in the plot?
>Solution :
You could do it that way
from sympy import symbols, latex
from sympy.plotting import plot
x = symbols("x")
exp = 2 + 3 * x**2
plot(exp, title='$'+latex(exp)+'$')
latex write the expression as a latex formula. And you need to enclose latex formula with $ so that sympy doesn’t treat the title as raw text.
