在做PAT的几何题是,为了方面看图,用一下python
读取文件x,y
import matplotlib.pyplot as plt import numpy as np with open("map.txt") as f: lines = f.readlines() n = int(lines[0]) x = [] y = [] for i in range(n): line = lines[i+1].split(" ") x.append(int(line[0])) y.append(int(line[1])) # 记号形状 颜色 点的大小 设置标签 plt.scatter(x, y, marker = 'x',color = 'red', s = 40 ,label = 'First') plt.legend(loc = 'best') # 设置 图例所在的位置 使用推荐位置 plt.show()