@@ -1131,7 +1131,7 @@ def show_simulation_progress(s):
1131
1131
print (f"{ s .W .TIME :>8.0f} s| { sum_vehs :>8.0f} vehs| { avev :>4.1f} m/s| { time .time ()- s .W .sim_start_time :8.2f} s" , flush = True )
1132
1132
1133
1133
@catch_exceptions_and_warn ()
1134
- def network_anim (s , animation_speed_inverse = 10 , detailed = 0 , state_variables = "density_speed" , minwidth = 0.5 , maxwidth = 12 , left_handed = 1 , figsize = (6 ,6 ), node_size = 2 , network_font_size = 20 , timestep_skip = 24 , file_name = None ):
1134
+ def network_anim (s , animation_speed_inverse = 10 , detailed = 0 , state_variables = "density_speed" , minwidth = 0.5 , maxwidth = 12 , left_handed = 1 , figsize = (6 ,6 ), node_size = 2 , network_font_size = 20 , timestep_skip = 24 , file_name = None , legend = True ):
1135
1135
"""
1136
1136
Generates an animation of the entire transportation network and its traffic states over time.
1137
1137
@@ -1163,6 +1163,8 @@ def network_anim(s, animation_speed_inverse=10, detailed=0, state_variables="den
1163
1163
How many timesteps are skipped per frame. Large value means coarse and lightweight animation. Default is 8.
1164
1164
file_name : str, optional
1165
1165
The name of the file to which the animation is saved. It overrides the defauld name. Default is None.
1166
+ legend : bool, optional
1167
+ If set to True, the legend will be displayed. Default is True.
1166
1168
1167
1169
Notes
1168
1170
-----
@@ -1184,10 +1186,10 @@ def network_anim(s, animation_speed_inverse=10, detailed=0, state_variables="den
1184
1186
if int (t / s .W .LINKS [0 ].edie_dt ) < s .W .LINKS [0 ].k_mat .shape [0 ]:
1185
1187
if detailed :
1186
1188
#todo_later: 今後はこちらもpillowにする
1187
- s .network (int (t ), detailed = detailed , state_variables = state_variables , minwidth = minwidth , maxwidth = maxwidth , left_handed = left_handed , tmp_anim = 1 , figsize = figsize , node_size = node_size , network_font_size = network_font_size )
1189
+ s .network (int (t ), detailed = detailed , state_variables = state_variables , minwidth = minwidth , maxwidth = maxwidth , left_handed = left_handed , tmp_anim = 1 , figsize = figsize , node_size = node_size , network_font_size = network_font_size , legend = legend )
1188
1190
pics .append (Image .open (f"out{ s .W .name } /tmp_anim_{ t } .png" ))
1189
1191
else :
1190
- img_ret = s .network_pillow (int (t ), detailed = detailed , state_variables = state_variables , minwidth = minwidth , maxwidth = maxwidth , left_handed = left_handed , tmp_anim = 1 , figsize = figsize , node_size = node_size , network_font_size = network_font_size , image_return = True )
1192
+ img_ret = s .network_pillow (int (t ), detailed = detailed , state_variables = state_variables , minwidth = minwidth , maxwidth = maxwidth , left_handed = left_handed , tmp_anim = 1 , figsize = figsize , node_size = node_size , network_font_size = network_font_size , image_return = True , legend = legend )
1191
1193
pics .append (img_ret )
1192
1194
1193
1195
fname = f"out{ s .W .name } /anim_network{ detailed } .gif"
0 commit comments