簡體   English   中英

Seaborn distplot與來自不同陣列的rugplot

[英]Seaborn distplot with rugplot from different array

使用seaborn用地毯制作一個distplot很容易:

import seaborn as sns, numpy as np
%matplotlib inline
sns.set(rc={"figure.figsize": (8, 4)}); np.random.seed(0)
x = np.random.randn(100)
ax = sns.distplot(x, rug=True)

上面的地圖反映了分布x 但是如果我想在x的dist曲線下顯示來自不同發行版rug_array的地毯呢?

rug_array = np.array([-2.0, -1, 0, 1, 2, 2.1, 3])

答案應顯示曲線x的圖,其中地圖繪制標記為-2,-1,0,1,2,2.1和3。

Seaborn提供了一個功能rugplot繪制rugplot。 想法是使用這個功能。

import seaborn as sns
import numpy as np; np.random.seed(0)
import matplotlib.pyplot as plt

x = np.random.randn(100)
rug_array = np.array([-2.0, -1, 0, 1, 2, 2.1, 3])

ax = sns.distplot(x, rug=False)
sns.rugplot(rug_array, height=0.05, axis='x', ax=ax)

plt.show()

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM