Python Forum
How to plot histogram from 2 arrays?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to plot histogram from 2 arrays?
#1
I have two arrays where the first array shows the unique values extracted from a column and the second array stores the frequency of these unique values. How can I correctly plot the histogram?

(array([0, 1, 2, 3, 4], dtype=uint8), array([ 1, 20, 20, 30, 45], dtype=int64))

0,1,2,3,4 are the unique values and the numbers in the second array shows the frequency of each of the value.

I tried to do the code as below but it is not producing the correct histogram

b = ([0,1,2,3,4],[1,20,20,39,45])
x = b[0]
print (x)
y = b[1]
print(y)
plt.hist([x,y], bins='auto') 
plt.show()]
Thank you
Reply


Messages In This Thread
How to plot histogram from 2 arrays? - by python_newbie09 - Mar-25-2019, 08:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unhashable error - Histogram code lsbpython 1 1,014 Aug-07-2022, 04:02 PM
Last Post: Yoriz
  Plot arrays against each other fabstr1 3 2,133 Sep-14-2021, 03:02 PM
Last Post: deanhystad
  How to plot intraday data of several days in one plot mistermister 3 2,944 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Help with Plotting Histogram Shimmy 1 39,452 Oct-25-2019, 08:20 AM
Last Post: newbieAuggie2019
  How to plot vertically stacked plot with same x-axis and SriMekala 0 1,953 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  How to: Plot a 2D histogram from N-dim array? StevenZ 1 2,489 Mar-31-2018, 04:08 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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