Created
January 24, 2017 01:24
-
-
Save chrisb13/069c8fae470e52aea2ef3af213f69c97 to your computer and use it in GitHub Desktop.
Matplotlib toy example using LaTeX labels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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