我成功地制作了我的第一张gif图形,但我仍然不知道如何解决越来越多的日期拥挤的问题。大约有365个日期轴
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)
目前没有回答
相关问题 更多 >
编程相关推荐