1616# along with structure_threader. If not, see <http://www.gnu.org/licenses/>.
1717
1818
19+ import os
20+ from collections import Counter , defaultdict
21+ import numpy as np
1922import matplotlib
23+ import matplotlib .pyplot as plt
2024matplotlib .use ('Agg' )
2125
22- import matplotlib .pyplot as plt
23- import numpy as np
24- from collections import Counter , defaultdict
25- import os
2626
2727def parse_usepopinfo (fhandle , end_string ):
2828 """
@@ -201,7 +201,7 @@ def plotter(qvalues, poplist, outfile):
201201 plt .rcParams ["figure.figsize" ] = (8 * numinds * .01 , 2.64 )
202202
203203 fig = plt .figure ()
204- ax = fig .add_subplot (111 , xlim = (0 , numinds ), ylim = (0 , 1 ))
204+ axe = fig .add_subplot (111 , xlim = (0 , numinds ), ylim = (0 , 1 ))
205205
206206 for i in range (qvalues .shape [1 ]):
207207 # Get bar color. If K exceeds the 12 colors, generate random color
@@ -211,19 +211,19 @@ def plotter(qvalues, poplist, outfile):
211211 clr = np .random .rand (3 , 1 )
212212
213213 if i == 0 :
214- ax .bar (range (numinds ), qvalues [:, i ], facecolor = clr ,
215- edgecolor = "none" , width = 1 )
214+ axe .bar (range (numinds ), qvalues [:, i ], facecolor = clr ,
215+ edgecolor = "none" , width = 1 )
216216 former_q = qvalues [:, i ]
217217 else :
218- ax .bar (range (numinds ), qvalues [:, i ], bottom = former_q ,
219- facecolor = clr , edgecolor = "none" , width = 1 )
218+ axe .bar (range (numinds ), qvalues [:, i ], bottom = former_q ,
219+ facecolor = clr , edgecolor = "none" , width = 1 )
220220 former_q = former_q + qvalues [:, i ]
221221
222222 # Annotate population info
223223 if poplist :
224224 for i in zip (np .cumsum ([len (x [0 ]) for x in poplist ]), poplist ):
225225 orderings = [(x , y [0 ][0 ]) for x , y in
226- zip (np .cumsum ([len (x [0 ]) for x in poplist ]), poplist )]
226+ zip (np .cumsum ([len (x [0 ]) for x in poplist ]), poplist )]
227227 count = 1
228228 for ppl , vals in enumerate (orderings ):
229229
@@ -236,14 +236,14 @@ def plotter(qvalues, poplist, outfile):
236236 else vals [0 ] / 2
237237
238238 # Draw text
239- ax .text (xpos , - 0.05 , vals [1 ] if vals [1 ] else "Pop{}" .format (count ),
240- rotation = 45 , va = "top" , ha = "right" , fontsize = 6 ,
241- weight = "bold" )
239+ axe .text (xpos , - 0.05 , vals [1 ] if vals [1 ] else "Pop{}" .format (count ),
240+ rotation = 45 , va = "top" , ha = "right" , fontsize = 6 ,
241+ weight = "bold" )
242242 count += 1
243243
244244 for axis in ["top" , "bottom" , "left" , "right" ]:
245- ax .spines [axis ].set_linewidth (2 )
246- ax .spines [axis ].set_color ("black" )
245+ axe .spines [axis ].set_linewidth (2 )
246+ axe .spines [axis ].set_color ("black" )
247247
248248 plt .yticks ([])
249249 plt .xticks ([])
@@ -267,6 +267,6 @@ def main(result_files, fmt, outdir, popfile=None):
267267if __name__ == "__main__" :
268268 from sys import argv
269269 # Usage: structplot.py results_file format outdir
270- datafiles = []
271- datafiles .append (argv [1 ])
272- main (datafiles , argv [2 ], argv [3 ])
270+ DATAFILES = []
271+ DATAFILES .append (argv [1 ])
272+ main (DATAFILES , argv [2 ], argv [3 ])
0 commit comments