I am trying to add a title with the correct syntax to print the formula for a Gaussian distribution and don't see my mistake. Can someone help me spot it? My attempt is below and produces this result while the formula should look like f(x) = right hand side of this. I am asking for python3, though I think it's the same as LaTeX.
title = "Gaussian Distribution: f(x) = $\\frac{1/\sigma (2\pi)^{frac{1/2}}} \exp( \\frac{(x-\mu)^2 / 2\sigma^2} )"
plt.title(title)
MathText expressions must be enclosed by $
signs.
They must be valid latex commands, i.e. an opening {
must have a closing }
.
Using raw strings makes escaping unnecessary.
title = r"f(x) = $\frac{1}{\sigma \sqrt{2\pi}} e^{\frac{(x-\mu)^2 }{ 2\sigma^2}}$"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With