0
請幫助這個......我無法得到線的情節。它會繪製x,y散點圖,但不會出現趨勢線。Matplotlib趨勢線代碼..將運行,但不會繪製p(x)線....我不知道什麼是錯的。
import numpy as np
import matplotlib.pyplot as fs
name = ["SlowFast","Bedrock","MeanSlow","hAgDenkm","hSinDenkm","hAgSl","hAgFa","hSinSl","hSinF","LogSlowFast","LogBedrock","LogMeanSlow","LoghAgDenkm",#
"LoghSinDenkm","LoghAgSl","LoghAgFa","LoghSinSl","LoghSinFa"]
data = np.genfromtxt('C:\Users\Ben\Documents\R\LWM_Study\LWM52714BigRun.csv',dtype = 'float' , delimiter = ',' , skip_header = 0, skip_footer= 20 , names = name) ### data array###
x=data["LogSlowFast"]
y=data["LoghSinDenkm"]
z = np.polyfit(x,y,1)
p = np.poly1d(z)
fs.plot(x,y,'ro',x,p(x),'r--')
fs.ylabel("a")
fs.xlabel("LogSlowFast")
fs.show()
print x,y,z,p
你能向我們展示print語句的輸出嗎? – Gabriel