[英]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.