Created
October 30, 2014 18:35
-
-
Save mlohry/3a461db6dd1180100287 to your computer and use it in GitHub Desktop.
Matplotlib/PGF/LaTeX example py
This file contains 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 as mpl | |
import matplotlib.pyplot as plt | |
import numpy as np | |
fig_size=(4.5,2.5) | |
params = {'backend': 'pgf', | |
'axes.labelsize': 12, | |
'text.fontsize': 12, | |
'legend.fontsize': 12, | |
'xtick.labelsize': 12, | |
'ytick.labelsize': 12, | |
'text.usetex': True, | |
'figure.figsize': fig_size} | |
mpl.rcParams.update(params) | |
x = np.linspace(0, 1) | |
y = np.sin(4 * np.pi * x) * np.exp(-5 * x) | |
plt.fill(x, y, 'r', label=r"$y=e^{-5x} \sin 4 \pi x$") | |
plt.legend(loc='upper right') | |
plt.grid(True) | |
#plt.show() | |
plt.savefig('testpgf.pgf',bbox_inches='tight',pad_inches=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment