Skip to content

Instantly share code, notes, and snippets.

@chrisb13
Created January 24, 2017 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisb13/069c8fae470e52aea2ef3af213f69c97 to your computer and use it in GitHub Desktop.
Save chrisb13/069c8fae470e52aea2ef3af213f69c97 to your computer and use it in GitHub Desktop.
Matplotlib toy example using LaTeX labels
import matplotlib
import matplotlib.pyplot as plt
#nb requires latex installed on the machine, see http://matplotlib.org/users/usetex.html
from matplotlib import rc
import numpy as np
rc('text', usetex=True)
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.rm'] = 'Bitstream Vera Sans'
matplotlib.rcParams['mathtext.it'] = 'Bitstream Vera Sans:italic'
matplotlib.rcParams['mathtext.bf'] = 'Bitstream Vera Sans:bold'
plt.close('all')
fig=plt.figure()
ax=fig.add_subplot(1, 1,1)
cs1=ax.contourf(np.random.rand(10,10))
cb1=plt.colorbar(cs1,orientation='horizontal')
cb1.set_label(r"$\displaystyle ^{\circ} C$")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment