4

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?

2
  • 1
    Does tacf.head() return any data? Commented Feb 11, 2018 at 7:54
  • tacf.head(), not tacf.head. Commented Feb 11, 2018 at 8:12

1 Answer 1

2

Since you have pandas dataframe, you can u its plotting method:

tacf.plot(kind='bar')

Result for your data:

enter image description here

This is equivalent to:

plt.bar(tacf.index, tacf.iloc[:, 0])
plt.legend(tacf.columns)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.