#!/usr/bin/env python # -*- encoding: utf-8 -*- """ A script to do some plot for the MA 101 course, part 2, at Mahindra École Centrale. (C) Lilian BESSON ~ Janvier 2014 """ try: from ANSIColors import printc except: def printc(a): print(a) import sys import numpy as np #: To compute and use math tools import pylab #: To plot ################################################################### # I want now to plot some graphics about the datas, with matplotlib printc("\nPloting some graphics for the MA 101 course, part 2, at Mahindra École Centrale.") #: Graph options pylab.xlabel(u"Notes (entre $0$ et $%i$)" % noteMax) pylab.ylabel(u"Nombre d'élève(s) ayant eu cette note") pylab.title(u"Répartition des notes dans la classe") pylab.xlim(0, noteMax) pylab.xticks( np.arange(noteMax + 1) ) xvalues, bins, patches = pylab.hist(notes, np.arange(noteMax + 1), range=(0.,20.), facecolor='blue', alpha=0.0) pylab.ylim(0, xvalues.max() + 1) pylab.yticks( np.arange(xvalues.max() + 1) ) pylab.grid(True, alpha=0.3) #: Print only little stars for grades really presents idc = xvalues > 0 pylab.plot(bins[:-1][idc], xvalues[idc], 'g*--', linewidth=.5, markersize=18) pylab.xticks( bins[:-1][idc] ) # Tweak spacing to prevent clipping of ylabel pylab.subplots_adjust(left=0.15) # pylab.show() pylab.savefig(csv_name + "pdf") printc("Ploting the grades repartition on an histogram: " + csv_name + "pdf") pylab.draw() pylab.clf()