Skip to content

Instantly share code, notes, and snippets.

@yangle
Created November 11, 2011 23:00
Show Gist options
  • Save yangle/1359588 to your computer and use it in GitHub Desktop.
Save yangle/1359588 to your computer and use it in GitHub Desktop.
matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import datetime
infodict={'Author':'yAngle',
'CreationDate':datetime.datetime.today(),
'ModDate':datetime.datetime.today(),
}
fig=plt.figure(figsize=(3.4,2.2)) # 3.4 for RevTeX columnwidth, 2.2 ~ golden ratio
lbwh=[0.17, 0.15, 0.80, 0.81]
ax=fig.add_axes(lbwh)
x=np.linspace(0,2*np.pi,21)
ax.plot(x,np.sin(x))
if 1:
fig.savefig('abc.pdf')
plt.close()
else:
pdf=PdfPages('abc.pdf')
d=dict(infodict)
d['Title']='title'
pdf.infodict().update(d)
pdf.savefig(fig)
plt.close()
pdf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment