Skip to content

Commit

Permalink
added format strings for the plot titles, display insurers and reinsu…
Browse files Browse the repository at this point in the history
…rers side by side in sync
  • Loading branch information
AEL-H committed Aug 28, 2018
1 parent 0c8e4af commit 8599f7c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def __init__(self, data):
self.data = data
self.fig, self.ax = plt.subplots()
self.stream = self.data_stream()
self.ani = animation.FuncAnimation(self.fig, self.update, interval=40,
self.ani = animation.FuncAnimation(self.fig, self.update, repeat=False, interval=40,
init_func=self.setup_plot)

def setup_plot(self):
"""Initial drawing of the plots."""
casharr,idarr = next(self.stream)
self.pie = self.ax.pie(casharr, labels=idarr)
self.pie = self.ax.pie(casharr, labels=idarr,autopct='%1.0f%%')
return self.pie,

def data_stream(self):
Expand All @@ -52,15 +52,18 @@ def update(self, i):
self.ax.clear()
self.ax.axis('equal')
casharr,idarr = next(self.stream)
self.pie = self.ax.pie(casharr, labels=idarr)
self.ax.set_title("Timestep : " + str(i))
self.pie = self.ax.pie(casharr, labels=idarr,autopct='%1.0f%%')
self.ax.set_title("Timestep : {:,.0f} | Total cash : {:,.0f}".format(i,sum(casharr)))
return self.pie,

def save(self):
self.ani.save('line.mp4', writer='ffmpeg', dpi=80)
def save(self,filename):
self.ani.save(filename, writer='ffmpeg', dpi=80)

def show(self):
plt.show()

anim = InsuranceFirmAnimation(first_run_insurance)
anim.show()
anim1 = InsuranceFirmAnimation(first_run_insurance)
anim2 = InsuranceFirmAnimation(first_run_reinsurance)
#anim1.save("insurance.mp4")
#anim2.save("reinsurance.mp4")
plt.show()

0 comments on commit 8599f7c

Please sign in to comment.