File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -361,13 +361,15 @@ def _get_collection_shape(
361361 c = cmap (c )
362362 else :
363363 try :
364- norm = colors .Normalize (vmin = min (c ), vmax = max (c )) if norm is None else norm
364+ norm = colors .Normalize (vmin = np . nanmin (c ), vmax = np . nanmax (c )) if norm is None else norm
365365 except ValueError as e :
366366 raise ValueError (
367367 "Could not convert values in the `color` column to float, if `color` column represents"
368368 " categories, set the column to categorical dtype."
369369 ) from e
370- c = cmap (norm (c ))
370+ # normalize only the not nan values, else the whole array would contain only nan values
371+ c [~ c .isnull ()] = norm (c [~ c .isnull ()])
372+ c = cmap (c )
371373
372374 fill_c = ColorConverter ().to_rgba_array (c )
373375 fill_c [..., - 1 ] *= render_params .fill_alpha
@@ -769,6 +771,9 @@ def _set_color_source_vec(
769771
770772 # do not rename categories, as colors need not be unique
771773 color_vector = color_source_vector .map (color_mapping )
774+ # nan handling
775+ color_vector = color_vector .add_categories (na_color )
776+ color_vector [pd .isna (color_vector )] = na_color
772777
773778 return color_source_vector , color_vector , True
774779
You can’t perform that action at this time.
0 commit comments