1

I managed to make my first graph gif, but I still haven't figure out how to solve the issues of dates crowding as more increases. There are about 365 dates date axis.

fig = plt.figure()
#df7.plot(x = 'DateOfStop')
plt.xticks(rotation=45, ha="right", rotation_mode="anchor")
plt.subplots_adjust(bottom = 0.2, top = 0.9)
plt.xlabel('Dates')
plt.ylabel('Stops')
plt.tight_layout()

def buildmebarchart(i=int):
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_black, color ='red') 
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_white, color ='blue') 
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_Asian, color ='green')
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_AmericanIndian, color ='orange') 
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_Latinos, color ='purple')  
    plt.plot( df7[:i].DateOfStop, df7[:i].cum_PacificIslanders, color ='pink') 


animator = ani.FuncAnimation(fig,buildmebarchart, interval = 200)
#plt.show()
Writer = ani.writers['ffmpeg']
writer = Writer(fps=20, metadata=dict(artist='Me'), bitrate=1800)
animator.save('gif.mp4', writer = writer)

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

0 Answers0