@@ -294,10 +294,8 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
294294 elif sort_order and color_type == "cat" :
295295 # Null points go on bottom
296296 order = np .argsort (~ pd .isnull (color_source_vector ), kind = "stable" )
297- # Set orders
298- # Copy size before reordering so the original array is preserved
299- # across loop iterations (fixes #4024)
300- _size = size [order ] if isinstance (size , np .ndarray ) else size
297+ # `size` is not a loop variable, so don’t overwrite it here
298+ size_plot = size [order ] if isinstance (size , np .ndarray ) else size
301299 color_source_vector = color_source_vector [order ]
302300 color_vector = color_vector [order ]
303301 coords = basis_values [:, dims ][order , :]
@@ -349,11 +347,10 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
349347 )
350348 else :
351349 scatter = (
352- partial (ax .scatter , s = _size , plotnonfinite = True )
350+ partial (ax .scatter , s = size_plot , plotnonfinite = True )
353351 if scale_factor is None
354- else partial (
355- circles , s = _size , ax = ax , scale_factor = scale_factor
356- ) # size in circles is radius
352+ # size in circles is radius
353+ else partial (circles , s = size_plot , ax = ax , scale_factor = scale_factor )
357354 )
358355
359356 if add_outline :
@@ -367,7 +364,7 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
367364 # with some transparency.
368365
369366 bg_width , gap_width = outline_width
370- point = np .sqrt (_size )
367+ point = np .sqrt (size_plot )
371368 gap_size = (point + (point * gap_width ) * 2 ) ** 2
372369 bg_size = (np .sqrt (gap_size ) + (point * bg_width ) * 2 ) ** 2
373370 # the default black and white colors can be changes using
0 commit comments