@@ -294,9 +294,9 @@ 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- if isinstance ( size , np . ndarray ):
299- size = np .array (size )[order ]
297+ # Set orders — use a local to avoid cumulative reordering across
298+ # subplots when multiple color keys are given.
299+ _size = np .array (size )[order ] if isinstance ( size , np . ndarray ) else size
300300 color_source_vector = color_source_vector [order ]
301301 color_vector = color_vector [order ]
302302 coords = basis_values [:, dims ][order , :]
@@ -348,10 +348,10 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
348348 )
349349 else :
350350 scatter = (
351- partial (ax .scatter , s = size , plotnonfinite = True )
351+ partial (ax .scatter , s = _size , plotnonfinite = True )
352352 if scale_factor is None
353353 else partial (
354- circles , s = size , ax = ax , scale_factor = scale_factor
354+ circles , s = _size , ax = ax , scale_factor = scale_factor
355355 ) # size in circles is radius
356356 )
357357
@@ -366,7 +366,7 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915
366366 # with some transparency.
367367
368368 bg_width , gap_width = outline_width
369- point = np .sqrt (size )
369+ point = np .sqrt (_size )
370370 gap_size = (point + (point * gap_width ) * 2 ) ** 2
371371 bg_size = (np .sqrt (gap_size ) + (point * bg_width ) * 2 ) ** 2
372372 # the default black and white colors can be changes using
0 commit comments