2017-10-18 122 views
0

嗨較窄的人需要繪製分組變量的直方圖作爲寬直方圖隱藏df.plot.hist

df.groupby(['Variable1', 'Variable2']).plot.hist(bins=50) 

有沒有辦法讓所有的直方圖可見位置?首先繪製更大的繪圖,然後繪製更小的繪圖?

enter image description here

的結果阿爾法= 0.1還是很迷茫..

df.groupby(['Variable1', 'Variable2']).plot.hist(bins=50,alpha=0.1) 

enter image description here

+0

使用'alpha'較低的值? – akilat90

+0

在plot.hist中嘗試alpha = .05 –

+0

我嘗試過使用alpha = 0.5和alpha = 0.1,但它仍然非常困惑......是否有可能在背景上繪製較大的圖像? – gabboshow

回答

1

您可以通過改變alpha值更改劇情的不透明度。

df.groupby(['Variable1', 'Variable2']).plot.hist(bins=50,alpha=0.5)或使用你選擇的任何alpha值

或者,你可以繪製變量此起彼伏(這可能不是你問什麼)

這裏有一個演示:

p = np.random.normal(4, 1, 1000) 
s = np.random.normal(4, 2, 1000) 

df = pd.DataFrame({'A': p ,'B': s}) 

繪製數據幀

df.plot.hist() 

enter image description here

df.plot.hist(alpha = 0.5) 

enter image description here

繪圖一次一個一個變量,

df['A'].plot.hist() 
df['B'].plot.hist() 

enter image description here

改變繪製的序列;

df['B'].plot.hist() 
df['A'].plot.hist() 

enter image description here

+0

我試過alpha = 0.5和alpha = 0.1,但它仍然很困惑......是否有可能在背景上繪製更大的圖像? – gabboshow

+0

是的。但是,您一次只能指定每個變量。 – akilat90

+0

你可以發佈一些可重複的數據,所以我可以添加到答案? – akilat90