【发布时间】:2018-02-13 04:55:33
【问题描述】:
我正在使用 seaborn 绘制分布图。我想用不同的颜色在同一个图上绘制多个分布:
这是我开始分布图的方式:
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
iris = load_iris()
iris = pd.DataFrame(data= np.c_[iris['data'], iris['target']],columns= iris['feature_names'] + ['target'])
sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) target
0 5.1 3.5 1.4 0.2 0.0
1 4.9 3.0 1.4 0.2 0.0
2 4.7 3.2 1.3 0.2 0.0
3 4.6 3.1 1.5 0.2 0.0
4 5.0 3.6 1.4 0.2 0.0
sns.distplot(iris[['sepal length (cm)']], hist=False, rug=True);
'target' 列包含 3 个值:0、1、2。
我想查看一个萼片长度分布图,其中target ==0、target ==1 和target ==2,总共有 3 个图。
【问题讨论】:
-
来自
seaborn v0.11.0,使用sns.displot查看更新的答案,它取代了sns.distplot
标签: python seaborn histogram density-plot