#!/usr/bin/python from sys import argv import numpy as np import matplotlib.pyplot as plt if len(argv)<2: print "Please give at least 1 file id \n For example: 14 for Results.EGMF14 \n or 14 15 for EGMF14 and EGMF15" exit() # figure: energy distribution #============================= nbBins = 7 color=['b','g','r','c','m','y'] fig = plt.figure() ax = fig.add_subplot(111) ind = 0 for fileId in argv[1:]: weight,nbGen=np.loadtxt("Results_EGMF"+fileId+"/Results_extra",unpack=True,usecols=[2,3]) plt.hist(nbGen,nbBins,range=[2,9],log=1,facecolor=color[ind],alpha=.5, weights=weight, label="$10^{-%.0f"%float(fileId)+"}$Gauss") ind=ind+1 xtick=np.arange(9) ax.legend(loc='best') ax.set_xticks(xtick+0.5) ax.set_xticklabels(xtick) ax.set_xlabel("Generation") ax.set_ylabel("Number of events") plt.show()