@@ -78,7 +78,7 @@ def __init__(self, bbox=(-71.928864, 43.758201, -70.957947, 44.465151), font=Non
7878 if font is None :
7979 font = FontManager ().prop
8080 self .font = font
81- self .annotations = list ()
81+ self .annotations = []
8282
8383 @property
8484 def lats (self ):
@@ -162,17 +162,18 @@ def preprocess(
162162 values [np .logical_or (is_water , is_lake )] = np .nan
163163 values = vertical_ratio * values [- 1 ::- 1 ] # switch north and south
164164 return values
165-
165+
166+ # pylint: disable=too-many-arguments
166167 def add_annotation (
167- self ,
168- label = "Mount Washington" ,
169- coordinates = (- 71.3173 , 44.2946 ),
170- x_offset = - 0.25 ,
171- y_offset = - 0.045 ,
168+ self ,
169+ label = "Mount Washington" ,
170+ coordinates = (- 71.3173 , 44.2946 ),
171+ x_offset = - 0.25 ,
172+ y_offset = - 0.045 ,
172173 label_size = 30 ,
173174 annotation_size = 8 ,
174- color = None ,
175- background = True
175+ color = None ,
176+ background = True ,
176177 ):
177178 """Save an annotation.
178179
@@ -197,16 +198,18 @@ def add_annotation(
197198 background : bool
198199 If there is a background or not
199200 """
200- self .annotations .append ((
201- label ,
202- coordinates ,
203- x_offset ,
204- y_offset ,
205- label_size ,
206- annotation_size ,
207- color ,
208- background
209- ))
201+ self .annotations .append (
202+ (
203+ label ,
204+ coordinates ,
205+ x_offset ,
206+ y_offset ,
207+ label_size ,
208+ annotation_size ,
209+ color ,
210+ background ,
211+ )
212+ )
210213
211214 # pylint: disable=too-many-arguments,too-many-locals
212215 def plot_map (
@@ -265,17 +268,22 @@ def plot_map(
265268 -------
266269 matplotlib.Axes
267270 """
271+
268272 def plot_annotations ():
269273 """Plot the annotations.
270274
271- Takes all the annotations from self.annotations and adds them to the map
275+ Takes all the annotations from self.annotations and adds them to the map
272276 """
273277 for annotation in self .annotations :
274- rel_coordinates = ((annotation [1 ][0 ] - self .longs [0 ])/ (self .longs [1 ] - self .longs [0 ]),(annotation [1 ][1 ] - self .lats [0 ])/ (self .lats [1 ] - self .lats [0 ]))
278+ rel_coordinates = (
279+ (annotation [1 ][0 ] - self .longs [0 ])
280+ / (self .longs [1 ] - self .longs [0 ]),
281+ (annotation [1 ][1 ] - self .lats [0 ]) / (self .lats [1 ] - self .lats [0 ]),
282+ )
275283 annotation_color = ax .texts [0 ].get_color ()
276284 if annotation [6 ] is not None :
277285 annotation_color = annotation [6 ]
278-
286+
279287 ax .text (
280288 rel_coordinates [0 ] + annotation [2 ],
281289 rel_coordinates [1 ] + annotation [3 ],
@@ -284,20 +292,24 @@ def plot_annotations():
284292 size = annotation [4 ],
285293 color = annotation_color ,
286294 transform = ax .transAxes ,
287- bbox = {"facecolor" : background_color , "alpha" : 1 , "linewidth" : 1 } if annotation [7 ] else None ,
295+ bbox = (
296+ {"facecolor" : background_color , "alpha" : 1 , "linewidth" : 1 }
297+ if annotation [7 ]
298+ else None
299+ ),
288300 verticalalignment = "bottom" ,
289- zorder = len (values ) + 10
301+ zorder = len (values ) + 10 ,
290302 )
291-
303+
292304 ax .plot (
293- * rel_coordinates ,
294- 'o' ,
305+ * rel_coordinates ,
306+ "o" ,
295307 color = annotation_color ,
296308 transform = ax .transAxes ,
297309 ms = annotation [5 ],
298310 zorder = len (values ) + 10
299311 )
300-
312+
301313 if kind not in {"gradient" , "elevation" }:
302314 raise TypeError ("Argument `kind` must be one of 'gradient' or 'elevation'" )
303315 if values is None :
@@ -329,7 +341,7 @@ def plot_annotations():
329341
330342 ax .plot (x , y , "-" , color = color , zorder = idx , lw = linewidth )
331343 ax .fill_between (x , y_base , y , color = background_color , zorder = idx )
332-
344+
333345 if label_color is None :
334346 if callable (line_color ):
335347 label_color = line_color (0.0 )
@@ -354,7 +366,7 @@ def plot_annotations():
354366 for spine in ax .spines .values ():
355367 spine .set_visible (False )
356368 ax .set_facecolor (background_color )
357-
369+
358370 plot_annotations ()
359-
371+
360372 return ax
0 commit comments