2017-06-12 86 views
-2

我需要在單個窗口中繪製很多這樣的行(對於a0 .. a128)。我在FacetGridPairGrid以及遍佈各地搜索,但無法找到。只有regplot有類似的論點ax,但它不繪製直方圖。我的數據是帶有標籤列[0,1]的128個實值特徵。我需要從我的Python代碼中將這些圖形顯示爲Linux上的一個單獨的應用程序。單個窗口中的多個圖

enter image description here

此外,有規模這個柱狀圖顯示Y上的相對值,使得右曲線不歪斜的方法嗎?

g = sns.FacetGrid(df, col="Result") 
g.map(plt.hist, "a0", bins=20) 

plt.show() 
+0

這是一個有點不清楚您的環境和數據的模樣。使用matplotlib的子圖很容易。 FacetGrid可能會工作,這取決於你的數據框。關於你的標準化:matplotlib.hist需要'''density = True''',你應該可以把它發佈到seaborn。 – sascha

+0

更新了答案。你有一個例子如何使用一些FacetGrid的子圖嗎?我沒有通過那裏的副圖軸。 – VladimirLenin

+0

據我所知,FacetGrid應該取代次情節(整個subplot-thingy)。 **編輯:**啊,你想要FacetGrids的subplots ... ouch ...檢查文檔。我認爲FacetGrid是一個圖形對象(不是一個軸對象!),你會遇到問題。 – sascha

回答

1

只是一個簡單的例子,使用matplotlib。代碼沒有經過優化(難看,但情節簡單索引):

import numpy as np 
import matplotlib.pyplot as plt 

N = 5 

data = np.random.normal(size=(N*N, 1000)) 

f, axarr = plt.subplots(N, N) # maybe you want sharex=True, sharey=True 

pi = [0,0] 
for i in range(data.shape[0]): 
    if pi[1] == N: 
     pi[0] += 1 # next row 
     pi[1] = 0 # first column again 

    axarr[pi[0], pi[1]].hist(data[i], normed=True) # i was wrong with density; 
                # normed=True should be used 

    pi[1] += 1 

plt.show() 

輸出:

enter image description here