Browse Source

fixed the Conformations.visualise method bug

nicolas-zimmermann 4 years ago
parent
commit
05bc57ef6e
1 changed files with 12 additions and 9 deletions
  1. 12 9
      src/projet8.py

+ 12 - 9
src/projet8.py View File

@@ -9,7 +9,7 @@ from pyclustering.cluster.kmedoids import kmedoids
9 9
 from pyclustering.cluster import cluster_visualizer
10 10
 from pyclustering.utils import read_sample
11 11
 from pyclustering.samples.definitions import FCPS_SAMPLES
12
-
12
+import matplotlib.pyplot as plt
13 13
 
14 14
 class Conformations:
15 15
     """
@@ -156,31 +156,34 @@ class Conformations:
156 156
         x = np.arange(nb_confs)
157 157
         y = np.zeros(nb_confs)
158 158
 
159
-        for i in range(len(clusters_diss)):
160
-            for j in clusters_diss[i]:
159
+        for i in range(len(clusters)):
160
+            for j in clusters[i]:
161 161
                 y[j] = i+1
162 162
         
163 163
         color = []
164
+        #dict_col = {1:'b',2:'c',3:'',4:'',5:'',6:''}
164 165
         for i in y:
165 166
             if i == 1:
166 167
                 color.append('b')
167 168
             if i == 2:
168
-                color.append('c')
169
-            if i == 3:
170 169
                 color.append('g')
171
-            if i == 4:
170
+            if i == 3:
172 171
                 color.append('y')
173
-            if i == 5:
172
+            if i == 4:
174 173
                 color.append('r')
174
+            if i == 5:
175
+                color.append('c')
175 176
             if i == 6:
176 177
                 color.append('m')
177
-            else:
178
+            elif i > 6:
178 179
                 color.append('k')
179 180
 
180 181
         plt.bar(x, y, width=1.0, color=color)
181 182
         
182 183
         if output_name != None:
183
-            plt.savefig(output_name)
184
+            plt.savefig("results/"+output_name)
185
+
186
+        plt.close()
184 187
 
185 188
 if __name__ == "__main__":
186 189
     if len(sys.argv) < 2: