2626# Maximum number of bins in geo_bin_from_array
2727MAX_BINS = 200
2828
29- def geo_bin_from_array (array_sub , geo_coord , var_name , title , pop_name = True ,
30- buffer_deg = BUFFER_DEG , ignore_zero = False , ** kwargs ):
29+ def geo_bin_from_array (array_sub , geo_coord , var_name , title , pop_name = True ,\
30+ buffer_deg = BUFFER_DEG , extend = 'neither' , ** kwargs ):
3131 """Plot array values binned over input coordinates.
3232
3333 Parameters:
@@ -45,7 +45,8 @@ def geo_bin_from_array(array_sub, geo_coord, var_name, title, pop_name=True,
4545 array_sub.
4646 pop_name (bool, optional): add names of the populated places.
4747 buffer_deg (float, optional): border to add to coordinates
48- ignore_zero (bool, optional): ignore zero and negative values
48+ extend (str, optional): extend border colorbar with arrows.
49+ [ 'neither' | 'both' | 'min' | 'max' ]
4950 kwargs (optional): arguments for hexbin matplotlib function
5051
5152 Returns:
@@ -70,13 +71,6 @@ def geo_bin_from_array(array_sub, geo_coord, var_name, title, pop_name=True,
7071 if coord .shape [0 ] != array_im .size :
7172 raise ValueError ("Size mismatch in input array: %s != %s." % \
7273 (coord .shape [0 ], array_im .size ))
73- if ignore_zero and 0 in array_im :
74- pos_vals = array_im > 0
75- array_im = array_im [pos_vals ]
76- coord = coord [pos_vals , :]
77- kwargs_cbar = {'extend' :'min' }
78- else :
79- kwargs_cbar = {}
8074
8175 # Binned image with coastlines
8276 extent = get_borders (coord )
@@ -96,7 +90,7 @@ def geo_bin_from_array(array_sub, geo_coord, var_name, title, pop_name=True,
9690 cbax = make_axes_locatable (axis ).append_axes ('right' , size = "6.5%" , \
9791 pad = 0.1 , axes_class = plt .Axes )
9892 cbar = plt .colorbar (hex_bin , cax = cbax , orientation = 'vertical' ,
99- ** kwargs_cbar )
93+ extend = extend )
10094 cbar .set_label (name )
10195 axis .set_title (tit )
10296
0 commit comments