I am trying to plot world population map using geopandas and matplotlib. I also use matplotlib animation to make graph animated for each year.
import matplotlib.ticker as ticker
import matplotlib.animation as animation
from IPython.display import HTML
fig,ax=plt.subplots(1,1,figsize=(15,5))
def animation_bar(year):
filtered=df[df['Year']==year]
filtered.plot(ax=ax,column='Population',cmap='Reds',scheme='quantiles')
ax.set_title(int(year),fontweight='bold')
animator=animation.FuncAnimation(fig,animation_bar,frames=sorted(df['Year'].unique()),interval=300)
HTML(animator.to_jshtml())
I get two graphs as an output:
One graph is animated as intended, second one is static. One more concern about the output is that, the graph is smaller. As seen in the code I wanted the figsize=(15,5). It should be bigger than it is. I can't increase its size.
How to modify the code?