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

Skip to content

Commit a2eba0c

Browse files
committed
resolved flake8 issues
1 parent a6de6a4 commit a2eba0c

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed
Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
"""
22
==================
3-
Animated graph using funcAnimation
3+
Parameterized Animation Functions
44
==================
5-
use funcAnimation to create a graph of no of
6-
software engineers over the decades
5+
use FuncAnimation to show counts of widgets over the decades
76
"""
87
import matplotlib.pyplot as plt
9-
import matplotlib.animation as animation
108
import numpy as np
119

10+
import matplotlib.animation as animation
11+
1212
# Constants
1313
decades = np.arange(1940, 2020, 10)
14-
initial_engineers = 10000 # Rough estimate of the number of software engineers(not real) in the 1950s
14+
initial_widgets = 10000 # Rough estimate of the no. of widgets in the 1950s
1515

1616
# Generate rough growth data
1717
growth_rate = np.random.uniform(1.02, 3.10, size=len(decades))
18-
engineers_data = np.cumprod(growth_rate) * initial_engineers
18+
widgets_data = np.cumprod(growth_rate) * initial_widgets
1919

2020
# Set up the initial plot
2121
fig, ax = plt.subplots()
2222
ax.set_xlim(1940, 2020)
23-
ax.set_ylim(0, max(engineers_data) + 100000)
24-
line, = ax.plot([], [], label='Software Engineers')
23+
ax.set_ylim(0, max(widgets_data) + 100000)
24+
line, = ax.plot([], [])
2525
ax.set_xlabel('Decade')
26-
ax.set_ylabel('Number of Software Engineers')
27-
ax.legend()
26+
ax.set_ylabel('Number of Widgets')
2827

2928
# Text annotation to display the current decade
30-
text = ax.text(0.5, 0.85, '', transform=ax.transAxes, fontsize=12, ha='center', va='center')
29+
text = ax.text(0.5, 0.85, '', transform=ax.transAxes,
30+
fontsize=12, ha='center', va='center')
31+
3132

32-
def update(frame, line, text, decades, engineers_data):
33-
"""
34-
Update function for FuncAnimation.
33+
def update(frame, line, text, decades, widgets_data):
34+
# Update function for FuncAnimation.
3535

36-
Parameters:
37-
frame (int): The current frame number.
38-
line (Line2D): The line object to update.
39-
text (Text): The text annotation object to update.
40-
decades (numpy.ndarray): Array of decades.
41-
engineers_data (numpy.ndarray): Array of software engineers' data.
36+
# Parameters:
37+
# frame (int): The current frame number.
38+
# line (Line2D): The line object to update.
39+
# text (Text): The text annotation object to update.
40+
# decades (numpy.ndarray): Array of decades.
41+
# widgets_data (numpy.ndarray): Array of widgets' data.
42+
43+
# Returns:
44+
# tuple: Tuple containing the updated Line2D and Text objects.
4245

43-
Returns:
44-
tuple: Tuple containing the updated Line2D and Text objects.
45-
"""
4646
current_decade = decades[frame]
47-
current_engineers = int(engineers_data[frame])
47+
current_widgets = int(widgets_data[frame])
4848

49-
line.set_data(decades[:frame + 1], engineers_data[:frame + 1])
49+
line.set_data(decades[:frame + 1], widgets_data[:frame + 1])
5050

51-
text.set_text(f'Decade: {current_decade}\nEngineers: {current_engineers}')
51+
text.set_text(f'Decade: {current_decade}\nNumber of Widgets: {current_widgets}')
5252

5353
return line, text
5454

@@ -57,12 +57,9 @@ def update(frame, line, text, decades, engineers_data):
5757
fig, # Figure to update
5858
update, # Update function
5959
frames=len(decades), # Number of frames
60-
fargs=(line, text, decades, engineers_data), # Additional arguments for the update function
60+
fargs=(line, text, decades, widgets_data), # Additional arguments for update
6161
interval=1000, # Delay between frames in milliseconds
6262
blit=False, # Whether to use blit for faster updates
6363
)
6464

6565
plt.show()
66-
67-
68-

0 commit comments

Comments
 (0)