Skip to content

What summarization method is used in geopandas.GeoDataFrame.plot for multiple values? #2980

Answered by m-richards
lcoandrade asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @lcoandrade, thanks for the question. I hope I'm understanding it right based on the snippets you've shown, but no summation is done when plotting - all duplicates are layed on top, with the last record shown on top. This might help illustrate:

from geodatasets import get_path
import pandas as pd
import geopandas as gpd
gdf = gpd.read_file(get_path('nybb'))
gdf2 = pd.concat([gdf.iloc[[0]].assign(distance=i) for i in range(5)])
gdf2.plot(column='distance', cmap='viridis', legend=True)
gdf2.sort_values(by='distance', ascending=False).plot(column='distance', cmap='viridis', legend=True)

So you would need to take care of duplication / aggregation yourself before plotting.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lcoandrade
Comment options

Answer selected by lcoandrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants