import sys reload(sys) sys.setdefaultencoding(‘utf8‘) import matplotlib.pyplot as plt import string file = open("GD.txt") i = 0 x = range(0) y = range(0) for line in file: x.append(string.atoi(line[0:7], 10)) y.append(string.atoi(line[8:], 10)) print x[1] print "111111111111" #print y # plt.xlabel("x position") # plt.ylabel("y position") # plt.title("E track distribution diagram \n Red point is start and Blue point is end.") #plt.plot(x,y) plt.plot(x, y, ‘k--‘, linewidth=1, linestyle="-.") for i in range(94): plt.plot(x[i], y[i], ‘yo-‘, linewidth=1) plt.plot(x[0], y[0], ‘r*‘, linewidth=10) plt.plot(x[94], y[94], ‘b*‘, linewidth=10) plot(x, y) # plot x and y using blue circle markers plt.show()
import string import matplotlib.pyplot as plt import numpy as np file = open("picture.txt") i = 0 x = range(0) y = range(0) for line in file: x.append(string.atoi(line[0:7], 10)) y.append(string.atoi(line[8:], 10)) years = x price = y plt.plot(years, price, ‘b*‘) #,label=$cos(x^2)$) plt.plot(years, price, ‘r‘) plt.xlabel(years(+2000)) plt.ylabel("housing average price(*2000 yuan)") plt.ylim(0, 15) plt.title(‘line_regression & gradient decrease‘) plt.legend() plt.show()
时间: 2024-10-25 18:23:24