Dan*_*yal 3 python csv scatter matplotlib
我编写了一个脚本来计算尺寸为大的csv文件:27000行x 22列.如何在CSV文件中读取以便在matplotlib中使用它,就像这个线程中的散点图一样?
生成散点图的概念是可以理解的.已尝试通过以下方式解析csv文件:
data=csv.reader(open('some_file.csv, 'rb'), delimiter='|', quotechar='"')
Run Code Online (Sandbox Code Playgroud)
但没有成功.
这是一个快速的解决方案
def getColumn(filename, column):
results = csv.reader(open(filename), delimiter="\t")
return [result[column] for result in results]
Run Code Online (Sandbox Code Playgroud)
然后你可以像这样使用它
time = getColumn("filename",0)
volt = getColumn("filaname",1)
plt.figure("Time/Volt")
plt.xlabel("Time(ms)")
plt.ylabel("Volt(mV)")
plt.plot(time,volt)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19810 次 |
| 最近记录: |