I can make italic text like this:
plt.title('$\it{Text}$')
plt.show()
I'd like to have italic text and use the .format() function, e.g.:
plt.title('$\it{Text}$ = {}'.format(func))
plt.show()
This returns KeyError: 'Text'
CodePudding user response:
Or if only some of the desired text is to be italic:
text = "italic"
text2 = "something"
plt.title(f"$\it{text}$ ~ {text2}")
CodePudding user response:
I Hope I understood your question.
you can check this web if you wanna know more about format function: https://www.geeksforgeeks.org/python-string-format-method/
import matplotlib.pyplot as plt
s=[11,22,33,44,55,66]
a=[22,33,44,22,1,34]
plt.plot(a,s)
plt.title("{}".format("GLITCH"),style="italic")
plt.show()