Python Forum
How to: Plot a 2D histogram from N-dim array?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to: Plot a 2D histogram from N-dim array?
#1
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
Reply
#2
Please show enough code (including import statements) to run your example without searching for modules.
Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unhashable error - Histogram code lsbpython 1 1,082 Aug-07-2022, 04:02 PM
Last Post: Yoriz
  How to plot intraday data of several days in one plot mistermister 3 3,070 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Help with Plotting Histogram Shimmy 1 48,392 Oct-25-2019, 08:20 AM
Last Post: newbieAuggie2019
  How to plot vertically stacked plot with same x-axis and SriMekala 0 2,006 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  How to plot histogram from 2 arrays? python_newbie09 5 9,097 Mar-28-2019, 04:20 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020