10
10
11
11
# Constants
12
12
decades = np .arange (1940 , 2020 , 10 )
13
- initial_engineers = 10000 # Rough estimate of the number of software engineers(not real) in the 1950s
13
+ initial_widgets = 10000 # Rough estimate of the no. of widgets in the 1950s
14
14
15
15
# Generate rough growth data
16
16
growth_rate = np .random .uniform (1.02 , 3.10 , size = len (decades ))
17
- engineers_data = np .cumprod (growth_rate ) * initial_engineers
17
+ widgets_data = np .cumprod (growth_rate ) * initial_widgets
18
18
19
19
# Set up the initial plot
20
20
fig , ax = plt .subplots ()
21
21
ax .set_xlim (1940 , 2020 )
22
- ax .set_ylim (0 , max (engineers_data ) + 100000 )
22
+ ax .set_ylim (0 , max (widgets_data ) + 100000 )
23
23
line , = ax .plot ([], [])
24
24
ax .set_xlabel ('Decade' )
25
- ax .set_ylabel ('Number of Software Engineers ' )
25
+ ax .set_ylabel ('Number of Widgets ' )
26
26
27
27
# Text annotation to display the current decade
28
28
text = ax .text (0.5 , 0.85 , '' , transform = ax .transAxes , fontsize = 12 , ha = 'center' , va = 'center' )
29
29
30
- def update (frame , line , text , decades , engineers_data ):
30
+ def update (frame , line , text , decades , widgets_data ):
31
31
"""
32
32
Update function for FuncAnimation.
33
33
@@ -36,17 +36,17 @@ def update(frame, line, text, decades, engineers_data):
36
36
line (Line2D): The line object to update.
37
37
text (Text): The text annotation object to update.
38
38
decades (numpy.ndarray): Array of decades.
39
- engineers_data (numpy.ndarray): Array of software engineers ' data.
39
+ widgets_data (numpy.ndarray): Array of widgets ' data.
40
40
41
41
Returns:
42
42
tuple: Tuple containing the updated Line2D and Text objects.
43
43
"""
44
44
current_decade = decades [frame ]
45
- current_engineers = int (engineers_data [frame ])
45
+ current_widgets = int (widgets_data [frame ])
46
46
47
- line .set_data (decades [:frame + 1 ], engineers_data [:frame + 1 ])
47
+ line .set_data (decades [:frame + 1 ], widgets_data [:frame + 1 ])
48
48
49
- text .set_text (f'Decade: { current_decade } \n Engineers : { current_engineers } ' )
49
+ text .set_text (f'Decade: { current_decade } \n Number of Widgets : { current_widgets } ' )
50
50
51
51
return line , text
52
52
@@ -55,12 +55,9 @@ def update(frame, line, text, decades, engineers_data):
55
55
fig , # Figure to update
56
56
update , # Update function
57
57
frames = len (decades ), # Number of frames
58
- fargs = (line , text , decades , engineers_data ), # Additional arguments for the update function
58
+ fargs = (line , text , decades , widgets_data ), # Additional arguments for the update function
59
59
interval = 1000 , # Delay between frames in milliseconds
60
60
blit = False , # Whether to use blit for faster updates
61
61
)
62
62
63
63
plt .show ()
64
-
65
-
66
-
0 commit comments