#!/usr/local/bin/python from __future__ import print_function, division import sys import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import AutoMinorLocator ### read data filename = sys.argv[1] # get filename from input f = open(filename) xbin = [] edep = [] for line in f.readlines(): if line[0] != "#": line = line.split(',') xbin_i = int(line[0]) edep_i = float(line[3]) xbin.append(xbin_i) edep.append(edep_i) xbin = np.array(xbin) edep = np.array(edep) binsize = 0.2 # mm x = (xbin - 100)*binsize # subtract 100 to centre at x = 0 ### plot data plt.title("Lateral energy deposition at the Bragg peak") plt.xlabel("Lateral position [mm]") plt.ylabel("Energy deposited [MeV]") plt.scatter(x, edep, s=10, facecolor='b', lw=0) # set axes limits plt.xlim(-20, 20) plt.ylim(0, plt.ylim()[1]) plt.grid() #plt.show() # save figure plt.savefig("plots/" + filename[:-4] + ".png", dpi=600)