plt.title("$y = x^2$")
Note that backslashes '\' must be escaped (e.g. "\\alpha"), or used inside raw strings (e.g. r"\alpha").
'\'
"\\alpha"
r"\alpha"
Related:
References: