From d71e7b5a8d893ad02e48be60651bc1f194bc1ca1 Mon Sep 17 00:00:00 2001 From: NicolasBSN Date: Wed, 22 Mar 2017 11:20:02 +0100 Subject: [PATCH] Update graph.py --- parties/graph.py | 61 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/parties/graph.py b/parties/graph.py index c3f4253..3eb0c1a 100644 --- a/parties/graph.py +++ b/parties/graph.py @@ -498,20 +498,55 @@ def matRecup(i, param): return matR -#Couleur des Stratégies -CouleursStrat=['b','r','black','g','purple'] -fig=plt.figure() -fig.suptitle('Animation des stratégies') -cmap = mpl.colors.ListedColormap(["b","r" ,"black" ,"g" ,"purple"]) -bounds=[0,1,2,3,4,5] -norm=mpl.colors.BoundaryNorm(bounds, cmap.N) -img=plt.imshow(matRecup(0, 'strategie'), interpolation = "nearest", cmap = cmap , norm = norm) -for i in range(0, 12): - print(matRecup(i, 'etat')) -cb=plt.colorbar(img , cmap=cmap , norm=norm , boundaries = bounds , ticks=bounds) -labels = np.arange(0, 5, 1) -cb.set_ticklabels(labels) +def animation_strat(): + fig=plt.figure() + fig.suptitle('Animation des stratégies') + cmap = mpl.colors.ListedColormap(["black","green" ,"red" ,"blue" ,"yellow"]) + bounds=[0,1,2,3,4,5] + norm=mpl.colors.BoundaryNorm(bounds, cmap.N) + img=plt.imshow(matRecup(0, 'strategie'), interpolation = "nearest", cmap = cmap , norm = norm) + + cb=plt.colorbar(img , cmap=cmap , norm=norm , boundaries = bounds , ticks=bounds) + labels = np.arange(1, 6, 1) + cb.set_ticklabels(labels) + + + + + + def update(next_iteration,*args): + img.set_array(matRecup(next_iteration , 'strategie')) + return [img] + + anim = animation.FuncAnimation(fig, update, frames=range(MaxIterations), interval=1000, repeat = False) + plt.show() + + + +def animation_etat(): + fig=plt.figure() + fig.suptitle('Animation des états') + cmap = mpl.colors.ListedColormap(["black","white"]) + bounds=[0,1,2] + norm=mpl.colors.BoundaryNorm(bounds, cmap.N) + img=plt.imshow(matRecup(0, 'etat'), interpolation = "nearest", cmap = cmap , norm = norm) + + cb=plt.colorbar(img , cmap=cmap , norm=norm , boundaries = bounds , ticks=bounds) + labels = np.arange(0, 2, 1) + cb.set_ticklabels(labels) + + + + + + def update(next_iteration,*args): + img.set_array(matRecup(next_iteration , 'etat')) + return [img] + + anim = animation.FuncAnimation(fig, update, frames=range(MaxIterations), interval=1000, repeat = False) + plt.show() +