@@ -195,40 +195,41 @@ def motor_torque(omega, params={}):
195
195
# angular velocity of the engine, while the curve on the right shows
196
196
# torque as a function of car speed for different gears.
197
197
198
- plt . figure ()
199
- plt .suptitle ( 'Torque curves for typical car engine' )
200
-
201
- # Figure 4.2a - single torque curve as function of omega
202
- omega_range = np . linspace ( 0 , 700 , 701 )
203
- plt . subplot ( 2 , 2 , 1 )
204
- plt .plot (omega_range , [ motor_torque (w ) for w in omega_range ] )
205
- plt . xlabel (r'Angular velocity $\omega$ [rad/s]' )
206
- plt . ylabel ('Torque $T$ [Nm]' )
207
- plt .grid (True , linestyle = 'dotted' )
208
-
209
- # Figure 4.2b - torque curves in different gears, as function of velocity
210
- plt . subplot ( 2 , 2 , 2 )
211
- v_range = np .linspace (0 , 70 , 71 )
198
+ # Figure 4.2
199
+ fig , axes = plt .subplots ( 1 , 2 , figsize = ( 7 , 3 ) )
200
+
201
+ # (a) - single torque curve as function of omega
202
+ ax = axes [ 0 ]
203
+ omega = np . linspace ( 0 , 700 , 701 )
204
+ ax .plot (omega , motor_torque (omega ) )
205
+ ax . set_xlabel (r'Angular velocity $\omega$ [rad/s]' )
206
+ ax . set_ylabel ('Torque $T$ [Nm]' )
207
+ ax .grid (True , linestyle = 'dotted' )
208
+
209
+ # (b) - torque curves in different gears, as function of velocity
210
+ ax = axes [ 1 ]
211
+ v = np .linspace (0 , 70 , 71 )
212
212
alpha = [40 , 25 , 16 , 12 , 10 ]
213
213
for gear in range (5 ):
214
- omega_range = alpha [gear ] * v_range
215
- plt . plot ( v_range , [ motor_torque (w ) for w in omega_range ],
216
- color = 'blue ' , linestyle = 'solid' )
214
+ omega = alpha [gear ] * v
215
+ T = motor_torque (omega )
216
+ plt . plot ( v , T , color = '#1f77b4 ' , linestyle = 'solid' )
217
217
218
218
# Set up the axes and style
219
- plt .axis ([0 , 70 , 100 , 200 ])
220
- plt .grid (True , linestyle = 'dotted' )
219
+ ax .axis ([0 , 70 , 100 , 200 ])
220
+ ax .grid (True , linestyle = 'dotted' )
221
221
222
222
# Add labels
223
223
plt .text (11.5 , 120 , '$n$=1' )
224
- plt .text (24 , 120 , '$n$=2' )
225
- plt .text (42.5 , 120 , '$n$=3' )
226
- plt .text (58.5 , 120 , '$n$=4' )
227
- plt .text (58.5 , 185 , '$n$=5' )
228
- plt .xlabel ('Velocity $v$ [m/s]' )
229
- plt .ylabel ('Torque $T$ [Nm]' )
230
-
231
- plt .tight_layout (rect = [0 , 0.03 , 1 , 0.95 ]) # Make space for suptitle
224
+ ax .text (24 , 120 , '$n$=2' )
225
+ ax .text (42.5 , 120 , '$n$=3' )
226
+ ax .text (58.5 , 120 , '$n$=4' )
227
+ ax .text (58.5 , 185 , '$n$=5' )
228
+ ax .set_xlabel ('Velocity $v$ [m/s]' )
229
+ ax .set_ylabel ('Torque $T$ [Nm]' )
230
+
231
+ plt .suptitle ('Torque curves for typical car engine' )
232
+ plt .tight_layout ()
232
233
plt .show (block = False )
233
234
234
235
# Figure 4.3: Car with cruise control encountering a sloping road
0 commit comments