Python Forum

Full Version: How to: Plot a 2D histogram from N-dim array?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone!

So I have been searching for some time to an answer. What I want to do is: Make 2 histograms, Divide them->Plot the result.

For some reason I can't find an answer..

x = [1,2,3,1,2,3,1,2,3]
y = [1,2,3,2,3,1,3,1,2]
plt.figure()
plt.subplot(221)
h1, x1, y1,im1 = plt.hist2d(x,y, bins=[5,5])
plt.subplot(222)
h2, x2, y2,im2 = plt.hist2d(x,y,bins=[5,5])
h3 = h1/h2


So h1 and h2 are in this case 5x5 dimensional arrays, h3 is aswell. Now I want to plot a new histogram with the same binning as h1 and h2 but with the values in h3.. Should not be to difficult right? I could use pyROOT or something for this but I switched to python for the easiness in plotting so going back to ROOT kind of makes no sense in this case..

Kind Regards Steven
Please show enough code (including import statements) to run your example without searching for modules.
Thank you.