@@ -236,10 +236,7 @@ def _dexplore(
236
236
nan_color = np .append (nan_color , [255 ])
237
237
else :
238
238
raise ValueError ("nan_color must be an iterable of 3 or 4 values" )
239
- if cmap not in colormaps :
240
- raise ValueError (
241
- f"`cmap` must be one of { list (colormaps .keys ())} but { cmap } was passed"
242
- )
239
+
243
240
# only polygons have z
244
241
if ["Polygon" , "MultiPolygon" ] in gdf .geometry .geom_type .unique ():
245
242
layer_kwargs ["get_elevation" ] = elevation
@@ -260,6 +257,10 @@ def _dexplore(
260
257
raise ValueError (f"the designated column { column } is not in the dataframe" )
261
258
if gdf [column ].dtype in ["O" , "category" ]:
262
259
categorical = True
260
+ if cmap is not None and cmap not in colormaps :
261
+ raise ValueError (
262
+ f"`cmap` must be one of { list (colormaps .keys ())} but { cmap } was passed"
263
+ )
263
264
if cmap is None :
264
265
cmap = "Set1" if categorical else "viridis"
265
266
if categorical :
@@ -312,7 +313,6 @@ def _get_categorical_cmap(categories, cmap, nan_color, alpha):
312
313
) from e
313
314
314
315
cat_codes = pd .Series (pd .Categorical (categories ).codes , dtype = "category" )
315
- BOTTOM = False if - 1 in cat_codes else True
316
316
317
317
# nans are encoded as -1 OR largest category depending on input type
318
318
# re-encode to always be last category
@@ -323,10 +323,8 @@ def _get_categorical_cmap(categories, cmap, nan_color, alpha):
323
323
324
324
colors = colormaps [cmap ].resampled (n_cats )(list (range (n_cats )), alpha )
325
325
colors = (np .array (colors ) * 255 ).astype (int )
326
- if BOTTOM :
327
- colors = np .vstack ([colors , nan_color ])
328
- else :
329
- colors = np .vstack ([nan_color , colors ])
326
+ colors = np .vstack ([colors , nan_color ])
327
+
330
328
331
329
n_colors = colors .shape [0 ]
332
330
0 commit comments