A similar question has already been asked on this: Plotting profile histograms in python. But never the less, it won't work for me, for some reason.
Let's look at my code
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import scipy
file = open('cesium.txt','r')
count = 0
energy_channel = []
intensity_counts = []
for line in file.readlines():
count += 1
if count >= 10:
row = line.split()
int_1 = int(row[0])
int_2 = int(row[-1])
energy_channel.append(int_1)
intensity_counts.append(int_2)
if count == 2700: break
plt.plot(energy_channel, intensity_counts, 'k.')
plt.xlabel('Energy (keV)')
plt.ylabel('Counts')
plt.xticks([0, 400, 800, 1200, 1600, 2000, 2400],
[0, 110, 220, 330, 440, 550, 662])
plt.show()
plt.clf()
This will plot a so called a gamma-spectrum for the radioactive isotope Cs-137 (for those who are intrested). Now, I would like to make a profile histogram out of this spectrum. Since I have all the points stored in the the two (x- and y-) vectors energy_channel and intensity_counts, respectively, I thought something like this might work:
scipy.stats.binned_statistic(energy_channel,intensity_counts)
But this simply gives me an error message:
FutureWarning:
Using a non-tuple sequence for multidimensional indexing is deprecated;
use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be
interpreted as an array index, `arr[np.array(seq)]`, which will result
either in an error or a different result.
I hope I am clear in my question here. I would like to make a profile histogram like in the thread I put a link to, but it doesn't seem to work as I think it will, and I can't figure it out.
Edit: I have tried making the lists into a tuple-list with the function zip() and then give it to the binned_statistics() function, but the same error message appears. I also tried making the lists into sequences, but it didn't seem to work either.