import matplotlib.pyplot as plt ax = plt.gca() # or any other way to get an axis object x = [0,1,2,3,4,5,6] y = [0,1,4,9,16,25,36] ax.plot(x, y, label=r'$\sin (x)$') ax.legend()Write a Latex formula in the legend of a plot using Matplotlib