@@ -425,10 +425,10 @@ def fit_bounds(self, bounds, padding_top_left=None,
425
425
426
426
def choropleth (self , geo_data , data = None , columns = None , key_on = None ,
427
427
bins = 6 , fill_color = 'blue' , nan_fill_color = '#000000b4' ,
428
- fill_opacity = 0.6 , line_color = 'black' , line_weight = 1 ,
429
- line_opacity = 1 , name = None , legend_name = '' , topojson = None ,
430
- reset = False , smooth_factor = None , highlight = None ,
431
- ** kwargs ):
428
+ fill_opacity = 0.6 , nan_fill_opacity = None , line_color = 'black' ,
429
+ line_weight = 1 , line_opacity = 1 , name = None , legend_name = '' ,
430
+ topojson = None , reset = False , smooth_factor = None ,
431
+ highlight = None , ** kwargs ):
432
432
"""
433
433
Apply a GeoJSON overlay to the map.
434
434
@@ -487,6 +487,8 @@ def choropleth(self, geo_data, data=None, columns=None, key_on=None,
487
487
(which is black '#000000' at ~0.71 opacity 'b4').
488
488
fill_opacity: float, default 0.6
489
489
Area fill opacity, range 0-1.
490
+ nan_fill_opacity: float, default fill_opacity
491
+ Area fill opacity for nan or missing values, range 0-1.
490
492
line_color: string, default 'black'
491
493
GeoJSON geopath line color.
492
494
line_weight: int, default 1
@@ -534,6 +536,9 @@ def choropleth(self, geo_data, data=None, columns=None, key_on=None,
534
536
raise ValueError ('Please pass a valid color brewer code to '
535
537
'fill_local. See docstring for valid codes.' )
536
538
539
+ if nan_fill_opacity is None :
540
+ nan_fill_opacity = fill_opacity
541
+
537
542
if 'threshold_scale' in kwargs :
538
543
if kwargs ['threshold_scale' ] is not None :
539
544
bins = kwargs ['threshold_scale' ]
@@ -594,13 +599,11 @@ def color_scale_fun(x):
594
599
key_of_x = get_by_key (x , key_on )
595
600
596
601
if key_of_x not in color_data .keys ():
597
- # 1: opacity is handled within nan_fill_color
598
- return nan_fill_color , 1
602
+ return nan_fill_color , nan_fill_opacity
599
603
600
604
value_of_x = color_data [key_of_x ]
601
605
if np .isnan (value_of_x ):
602
- # 1: opacity is handled within nan_fill_color
603
- return nan_fill_color , 1
606
+ return nan_fill_color , nan_fill_opacity
604
607
605
608
color_idx = np .digitize (value_of_x , bin_edges , right = False ) - 1
606
609
return color_range [color_idx ], fill_opacity
0 commit comments