Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0dffe1

Browse files
committed
FIX: code convention
1 parent 2856383 commit c0dffe1

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

examples/animation/rain.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# -----------------------------------------------------------------------------
55
import matplotlib
66
import numpy as np
7-
matplotlib.use('TkAgg')
8-
matplotlib.rcParams['toolbar'] = 'None'
7+
matplotlib.use('TkAgg') # Required on OSX for animation
98
import matplotlib.pyplot as plt
109
from matplotlib.animation import FuncAnimation
1110

1211

1312
# Create new figure
1413
fig = plt.figure(figsize=(7,7))
15-
fig.patch.set_facecolor('white')
1614
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1)
1715

1816
# Create rain data
@@ -23,7 +21,7 @@
2321

2422
# Scatter plot is used to animate rain drops
2523
scat = ax.scatter(P['position'][:,0], P['position'][:,1], P['size'], lw=0.5,
26-
animated=True, edgecolors = P['color'], facecolors='None')
24+
animated=True, edgecolors = P['color'], facecolors='none')
2725
ax.set_xlim(0,1), ax.set_xticks([])
2826
ax.set_ylim(0,1), ax.set_yticks([])
2927

@@ -32,22 +30,23 @@ def update(frame):
3230
i = frame % len(P)
3331

3432
# Make all colors more transparent
35-
P['color'][:,3] = np.maximum(0, P['color'][:,3] - 1.0/len(P))
33+
P['color'][:,3] -= 1.0/len(P)
34+
P['color'][:,3] = np.clip(P['color'][:,3], 0, 1)
3635

3736
# Make all circles bigger
3837
P['size'] += P['growth']
3938

4039
# Pick a new position for oldest rain drop
41-
P['position'][i] = np.random.uniform(0,1,2)
40+
P['position'][i] = np.random.uniform(0, 1, 2)
4241

4342
# Reset size
44-
P['size'][i] = 5
43+
P['size'][i] = 5
4544

4645
# Reset color
47-
P['color'][i] = 0,0,0,1
46+
P['color'][i] = (0, 0, 0, 1)
4847

4948
# Choose a random growth factor
50-
P['growth'][i] = np.random.uniform(50,200)
49+
P['growth'][i] = np.random.uniform(50, 200)
5150

5251
# Update scatter plot
5352
scat.set_edgecolors(P['color'])

0 commit comments

Comments
 (0)