Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

italic symbols in matplotlib?

I'm trying to get the gamma symbol to be italicised in a plot label but can't figure out how to do it?

I thought this should work (but doesn't)

plt.xlabel(r'$\mathit{\Gamma}$$^{*}$')

I should add I am using the Helvetica font, so don't want to switch into tex mode, e.g. this doesn't work for me:

import matplotlib
import matplotlib.pyplot as plt

plt.rcParams['font.family'] = "sans-serif"
plt.rcParams['font.sans-serif'] = "Helvetica"
plt.rcParams['text.usetex'] = True
plt.plot(range(5), range(5))
plt.title('$\Gamma + \mathit{\Gamma}$', fontsize=40)
plt.show()

thanks,

Martin

like image 295
user1516252 Avatar asked Sep 09 '15 02:09

user1516252


1 Answers

Write the text between '$$' that forces the text to be interpreted.

import matplotlib.pyplot as plt

plt.plot(range(5), range(5))
plt.title('$\it{text you want to show in italics}$')
plt.show()
like image 132
Homayoun Hamedmoghadam Avatar answered Sep 23 '22 02:09

Homayoun Hamedmoghadam