About x and y must be the same size Errors

Asked 2 years ago, Updated 2 years ago, 20 views

I'd like to read the csv file and plot it on the scatterplot, but it looks like this:

>>dcount=[j for i in range(14) for j in range(44)]
>>pyplot.scatter (dcount, data ['average'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/takumi/Ureka/python/lib/python 2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.eg/matplotlib/pyplot.py", line3200, insert
linewidths = linewidths, verts = verts, **kwargs)
  File "/home/takumi/Ureka/python/lib/python 2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/axes/_axes.py", line3592, inscatter
    raise ValueError("x and y must be the same size")
ValueError: x and y must be the same size

Please tell me what the problem is.Please!

python

2022-09-30 16:02

1 Answers

Arguments given to scatter must be the same length.

import matplotlib.pyplot as plt

# OK.
plt.scatter([0,1,10,100],[0,1,2,3])

# ValueError: x and y must be the same size
plt.scatter([0,1,10,100],[0,1])


2022-09-30 16:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.