-
Notifications
You must be signed in to change notification settings - Fork 0
/
plots.py
66 lines (40 loc) · 1.33 KB
/
plots.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
60
61
62
63
64
65
66
from include import *
from utils import *
def plot_lines(self, fig, x, y):
xmin = np.min(x)
xmax = np.max(x)
idx = np.invert(np.isnan(y))
ymin = np.min(y[idx])
ymax = np.max(y[idx])
bottom = 0.1
left = 0.11
right = 0.02
frac = 1. - left - right
top = 1. - bottom - frac
axes = fig.add_axes([left, bottom, frac, frac])
axes.plot(x, y)
axes.set_xlim(xmin = xmin, xmax = xmax)
axes.set_ylim(ymin = ymin, ymax = ymax)
return axes
def plot_pspace(self, fig, vals, bds, xfield, yfield):
# Draw image
bottom = 0.1
left = 0.11
right = 0.08
frac_cbar = 0.03
frac = 1. - left - right
top = 1. - bottom - frac_cbar - frac
ax = fig.add_axes([left, bottom, frac, frac])
im = ax.imshow(vals, cmap = mp.cm.jet, extent = bds, origin = 'lower', aspect = 'auto')
# Add labels
ax.set_xlabel(get_label(xfield))
ax.set_ylabel(get_label(yfield))
offset_x = 0.01
offset_y = 0.05
text = r'${\rm log}\,M/M_{\rm tot}$'
fig.text(left + frac + offset_x, bottom + frac + offset_y, text, rotation = 270)
# Add color bar
cax = fig.add_axes([left, bottom + frac, frac, frac_cbar])
fig.colorbar(im, cax = cax, orientation = 'horizontal')
cax.xaxis.set_ticks_position('top')
cax.yaxis.set_label_position('right')