Skip to content

Commit

Permalink
fix: pequeñas correcciones en mapas y etiquetas
Browse files Browse the repository at this point in the history
  • Loading branch information
zorzalerrante committed Sep 25, 2024
1 parent c7b3083 commit 6b61505
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/aves/visualization/maps/choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -159,6 +159,7 @@ def choropleth_map(
"cbar_axis": cbar_ax,
"built_palette": built_palette,
"bins": bins,
"binned_data": geodf["__bin__"],
}


Expand Down
11 changes: 8 additions & 3 deletions src/aves/visualization/maps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6b61505

Please sign in to comment.