Ejemplo n.º 1
0
                              alpha=1,
                              zorder=20))
        if display_num:
            plt.text(dfFrame.loc[pid]['x']-1,dfFrame.loc[pid]['y']-1.3,str(pid),fontsize=8, color='black', zorder=30)

    return fig, ax, dfFrame

anim = VideoClip(lambda x: mplfig_to_npimage(draw_frame(x)[0]), duration=length)

from scipy.spatial import Voronoi, voronoi_plot_2d
vor = Voronoi(anim)
import matplotlib.pyplot as plt
voronoi_plot_2d(anim)
plt.show()
#to save the animation to a file, uncomment the next line
anim.to_videofile(r'C:\Users\Home\Documents\working with positional data - version 1.mp4', fps=fps)

def count_players(dfFrame, pid):
    count = dfFrame.join(dfPlayers.team)[dfFrame['x']<=dfFrame.loc[pid]['x']].groupby('team').agg('count').max(axis=1)
    try:
        num_attack = count['attack']
    except KeyError:
        num_attack = 0
    try:
        num_defense = count['defense']
    except KeyError:
        num_defense = 0
    return (num_attack-num_defense)

def draw_area(t):
    fig, ax, dfFrame = draw_frame(t)
Ejemplo n.º 2
0
	def __init__(self):
		self.fig, self.ax = plt.subplots(1, 1)
		anim = VideoClip(lambda x: self.draw_swarmplot(x, self.fig, self.ax), duration=2)
		anim.to_videofile('swarmplot.mp4', fps=fps)