-
Notifications
You must be signed in to change notification settings - Fork 99
Description
Describe the bug
Creating a GeoDataFrame using geopandas in a format suitable for plot_animated applies a matplotlib colour map to each frame. In matplotlib, to display the colour map on the graph you turn on the "legend". This can be done by passing legend=True as an argument to the plot method.
pandas_alive permits supplying extra arguments to plot_animated which are passed on to plot. Unfortunately, matplotlib draws the colour map legend as another axis, so when used in plot_animated, each successive frame gets an additional colour map, ruining the effect.
To Reproduce
This is as per the documention, with the addition of legend=True
import geopandas
import pandas_alive
import contextily
gdf = geopandas.read_file('data/italy-covid-region.gpkg')
gdf.index = gdf.region
gdf = gdf.drop('region',axis=1)
map_chart = gdf.plot_animated(filename='examples/example-geo-polygon-chart.gif',basemap_format={'source':contextily.providers.Stamen.Terrain}, legend=True)
Expected behavior
The legend to appear in the animation, as it does for a single call to plot.
Screenshots
Additional context
The following diff on pandas_alive/geocharts.py fixes the issue:
184a185,191
> # Added by HR211010. If the user passes "legend=True", only apply to first frame.
> if i == 0:
> try:
> self.kwargs.pop("legend")
> except KeyError:
> pass
>
