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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
| if plot_it:
r = [math.sqrt(x**2 + y**2) for x,y in X]
x, y = zip(*X)
vx, vy = zip(*V)
tmin, tmax = min(T), max(T)
tcolor = [(tt-tmin)/(tmax-tmin) for tt in T]
tc2 = [tt*0.6 + 0.2 for tt in tcolor] # avoid dark red/blue
cmap = cm.jet
c, cfirst, clast = cmap(tc2), cmap(min(tc2)), cmap(max(tc2))
dgrey = (0.5, 0.5, 0.5) # darker gray
lgrey = (0.7, 0.7, 0.7) # lighter gray
fsl = 16 # font size for axis labels
fs = 14 # font size for tick labels
params = ['lines.color', 'xtick.color', 'ytick.color',
'axes.labelcolor']
for param in params:
plt.rcParams[param] = lgrey
plt.rcParams['axes.edgecolor'] = dgrey # this one darker
fig = plt.figure(figsize = (7.7,2.45)) # here is the figure
ax1 = fig.add_axes([0.08, 0.15, 0.25, 0.8]) # axes for three plots
ax2 = fig.add_axes([0.41, 0.15, 0.15, 0.8])
ax3 = fig.add_axes([0.64, 0.40, 0.30, 0.55])
fig.patch.set_alpha(0.0)
# FIRST PLOT
line = ax1.scatter(x, y, s=16) # scatter plot of all points
line.set_facecolors(c) # go back and change color of each one
line.set_edgecolors(c)
l = ax1.scatter(x[0], y[0], s=50) # make a big blue one for starting point
l.set_facecolors('b')
l = ax1.scatter(0.0, 0.0, s=120) # the sun!
l.set_facecolors((1.0, 1.0, 0.0)) # is yellow?
l.set_edgecolors((1.0, 0.7, 0.0)) # with an orange photosphere? not really!
ax1.arrow(x[0], y[0], 0.0, 0.25*a, head_width=0.08*a, head_length=0.16*a, fc='k', ec='k') #
hwbox = 1.6E+11
ax1.set_xlim([0.0 - hwbox, 0.0 + hwbox])
ax1.set_ylim([0.0 - hwbox, 0.0 + hwbox])
ax1.set_xlabel('x(m)', fontsize = fsl, color=lgrey)
ax1.set_ylabel('y(m)', fontsize = fsl, color=lgrey)
ax1.tick_params(axis='both', which='major', labelsize = fs, colors=lgrey)
# SECOND PLOT
hwbox = 2E+10
ax2.plot(x, y, '-k')
l = ax2.scatter(x[0], y[0], s=240)
l.set_facecolors(c[0])
line = ax2.scatter(x, y, s=60)
line.set_facecolors(c)
line.set_edgecolors(c)
ax2.arrow(x[0], y[0], 0.0, 0.25*hwbox, head_width=0.05*hwbox, head_length=0.1*hwbox, fc='k', ec='k') #
ax2.set_xlim([x[0] - 0.5*hwbox, x[0] + 0.5*hwbox])
ax2.set_ylim([y[0] - hwbox, y[0] + hwbox])
ax2.set_xlabel('x (m)', fontsize = fsl, color=lgrey)
ax2.set_ylabel('y (m)', fontsize = fsl, color=lgrey)
ax2.tick_params(axis='both', which='major', labelsize = fs, colors=lgrey)
# THIRD PLOT
ax3.plot(T, r, '-b', linewidth=6)
ax3.plot( [min(T), max(T)], [r_aphelion, r_aphelion], '-k')
ax3.plot( [min(T), max(T)], [r_perihelion, r_perihelion], '-k')
ax3.set_ylabel('r (m)', fontsize = fsl, color=lgrey)
ax3.set_xlabel('time (sec)', fontsize = fsl, color=lgrey)
ax3.tick_params(axis='both', which='major', labelsize = fs, colors=lgrey)
for ax in [ax1, ax2, ax3]:
ax.patch.set_facecolor(dgrey)
ax.patch.set_alpha(1.0)
line_1 = 'nstep = ' + str(nstep)
line_2 = 'gap = ' + str(round(gap,1)) + ' m'
line_3 = 'v_gap = ' + str(round(v_gap, 6)) + ' m/s'
fig.text(0.62, 0.19, line_1, horizontalalignment = 'left',
verticalalignment = 'center', fontsize = 16,
color = lgrey)
fig.text(0.62, 0.12, line_2, horizontalalignment = 'left',
verticalalignment = 'center', fontsize = 16,
color = lgrey)
fig.text(0.62, 0.05, line_3, horizontalalignment = 'left',
verticalalignment = 'center', fontsize = 16,
color = lgrey)
if save_it:
plt.savefig(save_name)
plt.show()
|