Skip to content

Instantly share code, notes, and snippets.

@renyuanL
Created November 14, 2021 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renyuanL/00b6ea11ac42ddacc06a8ea356f9008d to your computer and use it in GitHub Desktop.
Save renyuanL/00b6ea11ac42ddacc06a8ea356f9008d to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
#color= ['red', 'green', 'blue', 'magenta']
fig= plt.figure()
plt.xticks(rotation= 45,
ha= "right",
rotation_mode="anchor") #rotate the x-axis values
plt.subplots_adjust(bottom = 0.2,
top = 0.9,
left= .2,
right=.9) #ensuring the dates (on the x-axis) fit in the screen
plt.ylabel('$USD')
plt.xlabel('Date')
plt.title('Personal Value of Stock in USD$')
def buildmebarchart(i= int):
p= plt.plot(Y['Personal Value'][:i].index,
Y['Personal Value'][:i].values) #note it only returns the dataset, up to the point i
p[0].set_color('green') #set the colour of each curve
plt.legend(['Personal Value'])
plt.grid()
import matplotlib.animation as ani
animator= ani.FuncAnimation(fig,
buildmebarchart,
interval= 50,
repeat= True,
#cache_frame_data= False
)
#plt.show()
#animator.save('__ryPersonalValue.mp4', fps= 15)
animator.save('__ryPersonalValue.gif')
#plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment