I am using pyplot and numpy in python to show the plots of x^s where s = {2,3,4,5} and iterating for x^s and x^s. When using 'fr' to import my variable 'x' and its negative value, the superscript is only working for '-' and not '-2' for example. My code is as follows:
s = [2, 3, 4, 5]
for count, x in enumerate(s):
x1 = numpy.linspace(0, 2)
x2 = x1**x
pyplot.plot(x1, x2, label=fr"$x^{x}$")
x2 = x1**(-x)
pyplot.plot(x1, x2, label=fr"x$^{-x}$")
pyplot.xlim(-0.1, 2)
pyplot.ylim(-0.1, 3)
pyplot.legend()
pyplot.show()
Which outputs as:
I was expecting that the inputted variable '-x' would be completely superscripted. I have tried to change the variable outside of the pyplot.plot() however run into the same error.