2014-11-29 2 views
1
import matplotlib.pyplot as plt 
import matplotlib.mlab as mlab 
import numpy as np 
import matplotlib as mpl 
import seaborn as sns 
from scipy.stats import gaussian_kde 
from numpy import linspace,hstack 


LINE_WIDTH = 3 

filename=('') 
data=[ map(float, line.split()) for line in open(filename,'r') if line.strip()] 
dataM=np.array(data) 
meandata=np.mean(dataM,axis=0) 
SD = np.std(dataM,axis=0) 

sns.set_palette("hls") 
mpl.rc("figure", figsize=(8, 4)) 
xs = np.linspace(meandata[0]-(4 * SD[0]) ,meandata[0]+(4 * SD[0]), dataM[:,0].size) 
ys=dataM[:,0] 
n,bins,patches=plt.hist(ys,15) 

나는이 음모를 얻을.전나무 커널 분포는

enter image description here

와 나는 가우스 분포가 내 히스토그램을 통해 그려진 커널을하고 싶지만 나는 오류 형식 오류 점점 오전 : '모듈'개체가

내가이

을하려고 할 때 호출되지 않습니다 내가 잘못 뭐하는 거지
my_pdf = gaussian_kde(ys) 
x = linspace(30,100,1000) 
plt(x,my_pdf(x),'r') # distribution function 
plt.hist(ys,normed=1,alpha=.3) # histogram 
plt.show() 

?

+0

http://s17.postimg.org/jut9xqwcf/ssa.png – chrichat

+1

장소가 내 질문에 대한 링크. – AHuman

답변

0

는 직접 seaborn를 사용하여이 작업을 수행 할 수 있습니다. 그것은이 같은 것입니다 :

import pandas as pd 
import seaborn as sns 
import scipy.stats 
import matplotlib.pyplot as plt 

data = pd.read_csv('input.txt') 
sns.distplot(data, kde=False, fit=scipy.stats.norm) 
plt.show() 

KDE의 플롯 그냥 수행

sns.distplot(data); 

enter image description here

+0

예 sns.distplt를 사용했지만 3 시그마 규칙을 사용하여 영역을 채우고 싶지만 fill_between가 distplot과 작동하지 않거나 적어도 어떻게해야할지 모릅니다. 도와 드릴까요? 내가 가치 μ-2σ <데이터 chrichat

관련 문제