-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_figures.py
executable file
·59 lines (49 loc) · 1.44 KB
/
save_figures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import numpy as np
def multipage(filename, figs=None, dpi=200):
pp = PdfPages(filename)
if figs is None:
figs = [plt.figure(n) for n in plt.get_fignums()]
for fig in figs:
fig.savefig(pp, format='pdf')
pp.close()
# plt.figure('aa')
# plt.plot(np.arange(10))
# plt.figure(33)
# plt.plot(-np.arange(3, 50), 'r-')
# plt.figure()
# plt.plot(np.random.randn(10000), 'g-', rasterized=True)
def plot3D():
np.random.seed(0)
n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
xmin = x.min()
xmax = x.max()
ymin = y.min()
ymax = y.max()
plt.figure('bb')
plt.subplots_adjust(hspace=0.5)
plt.subplot(121)
plt.hexbin(x, y, cmap=plt.cm.YlOrRd_r)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("Hexagon binning")
cb = plt.colorbar()
cb.set_label('counts')
plt.subplot(122)
plt.hexbin(x, y, bins='log', cmap=plt.cm.YlOrRd_r)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("With a log color scale")
cb = plt.colorbar()
cb.set_label('log10(N)')
# plot3D()
# print (plt.get_fignums())
# print (plt.get_figlabels())
# for i in plt.get_fignums():
# print ('figure_%d.pdf' % i)
# # print (i)
# # print (plt.figure(i))
# # plt.savefig('figure%d.pdf' % i)
# for i in plt.get_figlabels():
# print ('figure_%s.pdf' % i)