使用matpoltlib读取csv显示图表范例

import os
import numpy as np
import matplotlib.pyplot as plt
root = os.getcwd()
list_data = [os.path.join(root, f) for f in os.listdir() if f.endswith('.txt')]
for file in list_data:
    data = np.loadtxt(file, dtype=np.str, delimiter=',')
    x = data[:,0]
    y = data[:,1]
    y = y.astype(np.float)
    fig, ax = plt.subplots()
    ax.plot(x, y)
    ax.set_title(file)

  

posted @ 2020-09-02 14:06  李浩的随笔-QQ812256  阅读(167)  评论(0编辑  收藏  举报