0

I want to visualize world population by year using GeoPandas. This is the code I am using :

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=merged[merged['Year']==year]  
    filtered.plot(ax=ax,column='Population_x',legend=True,cmap='Reds')

animator=animation.FuncAnimation(fig,animation_bar,frames=merged['Year'].unique(),interval=1000)
HTML(animator.to_jshtml())

The output looks like this:

enter image description here

How to modify the code for proper result?

beridzeg45
  • 246
  • 2
  • 11
  • Removed ",legend=True" and now the output looks much better and shows the animation properly. But there is the static second graph, which I want to be removed – beridzeg45 Oct 25 '22 at 12:32

0 Answers0