2017-08-15 68 views
0

我正在做一些EDA使用熊貓和seaborn,這是我所繪製的一組功能的直方圖代碼:避免overlaping上seaborn地塊

skewed_data = pd.DataFrame.skew(data) 
skewed_features =skewed_data.index 

fig, axs = plt.subplots(ncols=len(skewed_features)) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 
for i,skewed_feature in enumerate(skewed_features): 
    g = sns.distplot(data[column]) 
    sns.distplot(data[skewed_feature], ax=axs[i]) 

這是我得到的結果:

enter image description here

不可讀,如何避免這個問題?

+0

如果您在繪圖後調用'plt.tight_layout()',將會做很多工作。 – mwaskom

回答

1

我知道你是關於數字的佈局。但是,您需要先決定如何表示數據。這裏有兩個選擇,你的情況

(1)在一個數字,

(2)多的次要情節的2x2多條線路,每個插曲畫一條線。

我並不十分熟悉搜索引擎,但是搜索引擎的繪圖基於matplotlib。我可以給你一些基本的想法。

要存檔(1),您可以先聲明圖形和ax,然後將所有行添加到此ax。實施例的代碼:

import matplotlib.pyplot as plt 
fig, ax = plt.subplots() 
# YOUR LOOP, use the ax parameter 
for i in range(3) 
    sns.distplot(data[i], ax=ax) 

要存檔(2),與上述相同,但具有不同數目的副區,並把你的線在不同的副區。

# Four subplots, 2x2 
fig, axarr = plt.subplots(2,2) 
# YOUR LOOP, use different cell 

你可以檢查matplotlib subplots demo。做一個好的可視化是一項非常艱鉅的工作。有太多的文件要閱讀。檢查matplotlibseaborn的圖庫是瞭解如何實現某些類型可視化的好方法。

謝謝。