Reputation: 2738
I am showing relevant part of the code
import matplotlib.pyplot as plt
tacf = pd.DataFrame(data_acf)
print (type(tacf))
plt.bar(tacf,height=2.0)
plt.show()
Output
<class 'pandas.core.frame.DataFrame'>
File "/home/jh/miniconda3/lib/python3.6/site-packages/matplotlib/patches.py", line 351, in set_linewidth
self._linewidth = float(w)
TypeError: float() argument must be a string or a number, not 'NoneType'
If I go for tacf.head
<bound method NDFrame.head of 0
0 1.000000
1 0.942361
2 0.863303
3 0.794420
4 0.727603
5 0.671579
6 0.622612
7 0.570949
8 0.529410
9 0.497035
10 0.485163
11 0.479443
12 0.461094
13 0.444726
14 0.436634
I am confused with bars args and kwargs. Should I convert dataframe to different type or..?
How to plot dataframe as a bar with Matplotlib?
Upvotes: 4
Views: 4088
Reputation: 85512
Since you have pandas dataframe, you can u its plotting method:
tacf.plot(kind='bar')
Result for your data:
This is equivalent to:
plt.bar(tacf.index, tacf.iloc[:, 0])
plt.legend(tacf.columns)
Upvotes: 2