@@ -185,7 +185,7 @@ def _get_collection_shape(
185185 Args:
186186 - shapes (list[GeoDataFrame]): List of geometrical shapes.
187187 - c: Color parameter.
188- - s (float): Size of the shape.
188+ - s (float): Scale of the shape.
189189 - norm: Normalization for the color map.
190190 - fill_alpha (float, optional): Opacity for the fill color.
191191 - outline_alpha (float, optional): Opacity for the outline.
@@ -241,21 +241,30 @@ def assign_fill_and_outline_to_row(
241241 geom = row ["geometry" ]
242242 if geom .geom_type == "Polygon" :
243243 row = row .to_dict ()
244- row ["geometry" ] = mplp .Polygon (geom .exterior .coords , closed = True )
244+ coords = np .array (geom .exterior .coords )
245+ centroid = np .mean (coords , axis = 0 )
246+ scaled_coords = [(centroid + (np .array (coord ) - centroid ) * s ).tolist () for coord in geom .exterior .coords ]
247+ row ["geometry" ] = mplp .Polygon (scaled_coords , closed = True )
245248 assign_fill_and_outline_to_row (shapes , fill_c , outline_c , row , idx )
246249 rows .append (row )
247250
248251 elif geom .geom_type == "MultiPolygon" :
249- mp = _make_patch_from_multipolygon (geom )
250- for _ , m in enumerate ( mp ) :
252+ # mp = _make_patch_from_multipolygon(geom)
253+ for polygon in geom . geoms :
251254 mp_copy = row .to_dict ()
252- mp_copy ["geometry" ] = m
255+ coords = np .array (polygon .exterior .coords )
256+ centroid = np .mean (coords , axis = 0 )
257+ scaled_coords = [(centroid + (coord - centroid ) * s ).tolist () for coord in coords ]
258+ mp_copy ["geometry" ] = mplp .Polygon (scaled_coords , closed = True )
253259 assign_fill_and_outline_to_row (shapes , fill_c , outline_c , mp_copy , idx )
254260 rows .append (mp_copy )
255261
256262 elif geom .geom_type == "Point" :
257263 row = row .to_dict ()
258- row ["geometry" ] = mplp .Circle ((geom .x , geom .y ), radius = row ["radius" ])
264+ scaled_radius = row ["radius" ] * s
265+ row ["geometry" ] = mplp .Circle (
266+ (geom .x , geom .y ), radius = scaled_radius
267+ ) # Circle is always scaled from its center
259268 assign_fill_and_outline_to_row (shapes , fill_c , outline_c , row , idx )
260269 rows .append (row )
261270
@@ -576,7 +585,6 @@ def _prepare_cmap_norm(
576585
577586
578587def _set_outline (
579- size : float ,
580588 outline : bool = False ,
581589 outline_width : float = 1.5 ,
582590 outline_color : str | list [float ] = "#0000000ff" , # black, white
0 commit comments