diff --git a/src/aves/visualization/maps/choropleth.py b/src/aves/visualization/maps/choropleth.py index d5911d2..932969c 100644 --- a/src/aves/visualization/maps/choropleth.py +++ b/src/aves/visualization/maps/choropleth.py @@ -35,8 +35,8 @@ def choropleth_map( **kwargs, ): # grid ingresa este parĂ¡metro que NO usamos - if 'color' in kwargs: - del kwargs['color'] + if "color" in kwargs: + del kwargs["color"] geodf = geodf[pd.notnull(geodf[column])].copy() min_value, max_value = geodf[column].min(), geodf[column].max() @@ -159,6 +159,7 @@ def choropleth_map( "cbar_axis": cbar_ax, "built_palette": built_palette, "bins": bins, + "binned_data": geodf["__bin__"], } diff --git a/src/aves/visualization/maps/utils.py b/src/aves/visualization/maps/utils.py index 74df9e7..a473c9e 100644 --- a/src/aves/visualization/maps/utils.py +++ b/src/aves/visualization/maps/utils.py @@ -17,8 +17,11 @@ def geographical_labels( outline_width=2, format_func=None, bounds=None, + displacements=None, ): labels = [] + if not displacements: + displacements = {} for idx, row in geodf.iterrows(): centroid = row.geometry.centroid @@ -35,9 +38,11 @@ def geographical_labels( if format_func is not None: label = format_func(label) + disp = displacements.get(label, (0, 0)) + t = ax.text( - centroid.x, - centroid.y, + centroid.x + disp[0], + centroid.y + disp[1], label, va="center", horizontalalignment="center", @@ -89,7 +94,7 @@ def north_arrow( def geographical_scale(ax, location="lower left"): - ax.add_artist(ScaleBar(1, location="lower left")) + ax.add_artist(ScaleBar(1, location=location)) def add_basemap(