1

I've been following this post in order to connect points in a scatter plot with lines, the written code is:

import pandas as pd
import matplotlib.pyplot as plt
#data exploration
data = pd.read_csv("file.csv",encoding = 'utf8')
scan=[range(1,55)]
row2=data.iloc[1,1:]
plt.scatter(scan,row2)
#plt.plot(scan,row2)

If I remove the last line comment then terminal throws out:

ValueError: x and y must have same first dimension, but have shapes (1, 54) and (54,)

And prints only the scatterplot. Any help with this? I don't know how to build a complete MWE in this case (sorry for that).

1 Answers1

0

Try converting your range object to a list as

scan = list(range(1,55))
plt.scatter(scan, row2)
plt.plot(scan, row2)
Sheldore
  • 37,862
  • 7
  • 57
  • 71
  • perfect. Can you please describe briefly why it doesn't work? You don't have to, anyways. I don't understand why [ ] is different from list( ) –  May 24 '19 at 12:21