@@ -17,18 +17,22 @@ def _import_dependencies(self):
1717 def plot_static_elements (self , areas , locations ):
1818 # Plot the areas as squares
1919 if not self .plot_initialized :
20- self ._import_dependencies () # Import here, to avoid any missing dependency problems in case matplotlib is not installed
20+ # Import here, to avoid any missing dependency problems in case matplotlib is not installed
21+ self ._import_dependencies ()
2122
2223 self .fig , self .ax = plt .subplots ()
2324 self .ax .set_aspect ('equal' )
2425
2526 for area_name , area in areas .items ():
26- width = abs (area .upper_left_bound .latitude - area .lower_right_bound .latitude )
27- height = abs (area .upper_left_bound .longitude - area .lower_right_bound .longitude )
28- rect = Rectangle ((area .lower_right_bound .longitude , area .upper_left_bound .latitude ), height , width , alpha = 0.4 )
27+ width = abs (area .upper_left_bound .latitude -
28+ area .lower_right_bound .latitude )
29+ height = abs (area .upper_left_bound .longitude -
30+ area .lower_right_bound .longitude )
31+ rect = Rectangle ((area .lower_right_bound .longitude ,
32+ area .upper_left_bound .latitude ), height , width , alpha = 0.4 )
2933 self .ax .add_patch (rect )
30- self .ax .annotate (area_name , (area .lower_right_bound .longitude , area . upper_left_bound . latitude ), color = 'black' )
31-
34+ self .ax .annotate (area_name , (area .lower_right_bound .longitude ,
35+ area . upper_left_bound . latitude ), color = 'black' )
3236
3337 # Plot the locations
3438 colors = [
@@ -43,7 +47,8 @@ def plot_static_elements(self, areas, locations):
4347 ]
4448 ci = 0
4549 for location_name , location in locations .items ():
46- self .ax .plot (location .longitude , location .latitude , colors [ci % len (colors )], label = location_name )
50+ self .ax .plot (location .longitude , location .latitude ,
51+ colors [ci % len (colors )], label = location_name )
4752 ci += 1
4853
4954 # # Set the Atlantic area bounds atlantic_area = MapLib.atlantic_area width = abs(
@@ -85,7 +90,7 @@ def update_floating_objects(self, floating_objects):
8590
8691 # Plot the floating objects
8792 for obj in floating_objects :
88- if isinstance (obj , TitanicInOcean ):# Set the rotation angle in degrees
93+ if isinstance (obj , TitanicInOcean ): # Set the rotation angle in degrees
8994 angle_degrees = obj .direction
9095
9196 # Convert angle to radians
@@ -98,18 +103,20 @@ def update_floating_objects(self, floating_objects):
98103
99104 # Draw the arrow
100105 self .ax .annotate ("" , xy = (obj .longitude + dx , obj .latitude + dy ), xytext = (obj .longitude , obj .latitude ),
101- arrowprops = dict (arrowstyle = "->" ), gid = 'floating_object' )
106+ arrowprops = dict (arrowstyle = "->" ), gid = 'floating_object' )
102107
103108 if obj .sunk :
104109 icon = 'rs' # red square
105110 else :
106111 icon = 'ys' # yellow square
107112 # Draw the arrow
108113 self .ax .annotate ("" , xy = (obj .longitude + dx , obj .latitude + dy ), xytext = (obj .longitude , obj .latitude ),
109- arrowprops = dict (arrowstyle = '->' ), gid = 'floating_object' )
110- self .ax .plot (obj .longitude , obj .latitude , icon , label = 'Titanic' , gid = 'floating_object' )
114+ arrowprops = dict (arrowstyle = '->' ), gid = 'floating_object' )
115+ self .ax .plot (obj .longitude , obj .latitude , icon ,
116+ label = 'Titanic' , gid = 'floating_object' )
111117 elif isinstance (obj , Iceberg ):
112- self .ax .plot (obj .longitude , obj .latitude , 'w^' , label = 'Iceberg' , gid = 'floating_object' )
118+ self .ax .plot (obj .longitude , obj .latitude , 'w^' ,
119+ label = 'Iceberg' , gid = 'floating_object' )
113120
114121 # Redraw the plot
115122 plt .draw ()
0 commit comments