1. test.txt文件,数据以逗号分割,第一个数据为x坐标,第二个为y坐标,数据如下:1.1,2
2.1,23.1,34.1,540,3842,4143,422. python部分代码
#!/usr/bin/python# coding: utf-8import matplotlib.pyplot as pltimport numpy as npimport matplotlib as mplmpl.rcParams['font.family'] = 'sans-serif'mpl.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman'x, y = np.loadtxt('test.txt', delimiter=',', unpack=True)plt.plot(x, y, '*', label='Data', color='black')plt.xlabel('x')plt.ylabel('y')plt.title('Data')plt.legend()plt.show()3. 显示效果
以上这篇python 使用matplotlib 实现从文件中读取x,y坐标的可视化方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。