I am trying to write a text in the plot in italic. Although I want the style to be italic, I want to keep the font to be the regular font. This is what I did.
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlabel('X')
ax.set_ylabel('Y')
plt.axis([0, 4, 0, 4])
# Add R^2, and P-value
ax.text(1, 2, 'Adj$\mathregular{\mathit{R}^2}$ = 0.5 ($\mathregular{\mathit{P}}$ = 0.03)', fontsize = 20)
# R^2 and P should be italic with regular font
plt.show()
This is what I get and the font seemed to have changed to Times Roman or something. How could I fix this? Thank you for any help.