From 3716b099fe18ff458012084d344fce5f439d3532 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 30 Nov 2020 17:15:26 -0500 Subject: update code to work with python3 This commit updates the python code to work with python 3 and with a newer version of matplotlib. - zip_longest -> izip_longest - fix tick marks for log plots - scipy.misc -> scipy.special --- utils/plot-energy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'utils/plot-energy') diff --git a/utils/plot-energy b/utils/plot-energy index 4568bcc..2fb2aa1 100755 --- a/utils/plot-energy +++ b/utils/plot-energy @@ -31,7 +31,7 @@ from scipy.stats import iqr, poisson from matplotlib.lines import Line2D from scipy.stats import iqr, norm, beta from scipy.special import spence -from itertools import izip_longest +from itertools import chain particle_id = {20: 'e', 22: r'\mu'} @@ -56,6 +56,11 @@ def plot_hist2(df, muons=False): plt.hist(df_id.ke.values, bins=bins, histtype='step') plt.gca().set_xscale("log") plt.xlabel("Energy (MeV)") + major = np.array([10,100,1000,10000]) + minor = np.unique(list(chain(*list(range(i,i*10,i) for i in major[:-1])))) + minor = np.setdiff1d(minor,major) + plt.gca().set_xticks(major) + plt.gca().set_xticks(minor,minor=True) plt.title('$' + ''.join([particle_id[int(''.join(x))] for x in grouper(str(id),2)]) + '$') if len(df): -- cgit