使用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)

  

原文地址:https://www.cnblogs.com/qq812256/p/13601366.html