Tho*_*hew 3 python numpy matplotlib seaborn
使用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)
Run Code Online (Sandbox Code Playgroud)
上面的地毯图反映了分布x.但是,如果我想从不同的分布显示地毯,什么rug_array,下的dist情节下x?
rug_array = np.array([-2.0, -1, 0, 1, 2, 2.1, 3])
Run Code Online (Sandbox Code Playgroud)
答案应显示曲线图,地图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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
554 次 |
| 最近记录: |