Aaron
Aaron

Reputation: 165

Can't get y-axis on matplotlib histogram to display the right numbers

So I have this simple DataFrame which i am trying to plot a histogram with

    Hour    Count   Average Count
2      6       4         0.129032
4      7       1         0.032258
1     12       9         0.290323
3     16       3         0.096774
0     20    2022        65.225806

What I want is the Hour to be on the x-axis and Average Count to be on the Y axis. But when i tried this:

fig, hour = plt.subplots(1, 1)
hour.hist(test.Hour)
hour.set_xlabel('Time in 24 Hours')
hour.set_ylabel('Frequency')
plt.show()

I got this instead. I have tried doing test.Count and test['Average Count'] but both only affects the x-axis

enter image description here

Upvotes: 1

Views: 117

Answers (1)

moys
moys

Reputation: 8033

Are you looking for something like this? 'df' is the name of the dataframe.

df.plot(x='Hour', y = 'Averag Count', kind='bar')

Output

enter image description here

Upvotes: 1

Related Questions