Superscript Format In Matplotlib Plot Legend
I'm doing some curve fitting with the wonderful scipy curve fit. When plotting the data and adding a legend label to display the parameters calculated, using $^{}$ to make the betw
Solution 1:
In order to have MathText interprete the curly brackets they still need to be present after formatting. So you will want to use a pair of curly brackets, the inner ones for formatting, the outer ones for MathText functionality. The outer ones then still need to be escaped in order not to be used for formatting. This leads to 3 curly brackets.
label = ("$y = {{{}}}x^{{{}}}$").format(round(popt[0],2), round(popt[1],2))
Post a Comment for "Superscript Format In Matplotlib Plot Legend"