+ if args.stack:
+ stack.append((params,histogram))
+ else:
+ histogram.plot(
+ title=params,
+ filename='histogram{}.png'.format(
+ params.replace(' ','_')))
+ if stack:
+ # fairly similar to pysawsim.histogram.Histogram.plot
+ FIGURE.clear()
+ axes = FIGURE.add_subplot(1, 1, 1)
+ axes.hold(True)
+ bin_width = stack[0][1].bin_edges[1] - stack[0][1].bin_edges[0]
+ dx = bin_width / (2*len(stack)) # small offset for readability
+ for i,(params,histogram) in enumerate(stack):
+ n,bins,patches = axes.hist(
+ x=[x + i*dx for x in histogram.bin_edges[:-1]],
+ weights=histogram.probabilities,
+ bins=[x + i*dx for x in histogram.bin_edges],
+ align='mid', histtype='stepfilled',
+ alpha=0.15, label=params)
+ axes.legend(loc='best')
+ axes.set_title('histograms')
+ pyplot.show()
+ FIGURE.savefig(args.output)
+
+
+if __name__ == '__main__':
+ main()