美文网首页
数据可视化(2)seaborn

数据可视化(2)seaborn

作者: MWhite | 来源:发表于2018-05-31 14:50 被阅读0次

    seaborn

    import seaborn as sns


    sns.countplot(reviews['points'])
    sns.kdeplot(reviews.query('price < 200').price)
    reviews.query('price < 200') 与 reviews[reviews['price']<200] 等价
    A KDE plot is better than a line chart for getting the "true shape" of interval data 更平滑
    image.png
    image.png
    sns.kdeplot(reviews[reviews['price'] < 200].loc[:, ['price', 'points']].dropna().sample(5000))

    sns.distplot(reviews['points'], bins=10, kde=False)


    image.png

    sns.jointplot(x='price', y='points', data=reviews[reviews['price'] < 100])

    image.png

    sns.jointplot(x='price', y='points', data=reviews[reviews['price'] < 100], kind='hex', gridsize=20)

    df = reviews[reviews.variety.isin(reviews.variety.value_counts().head(5).index)]
    前五种类的数据
    sns.boxplot(
    x='variety',
    y='points',
    data=df
    )

    sns.violinplot(
    x='variety',
    y='points',
    data=reviews[reviews.variety.isin(reviews.variety.value_counts()[:5].index)]
    )

    双变量 faceting

    df = footballers[footballers['Position'].isin(['ST', 'GK'])]
    g = sns.FacetGrid(df, col="Position", col_wrap=6)
    g.map(sns.kdeplot, "Overall")


    image.png

    g = sns.FacetGrid(df, row="Position", col="Club")
    g.map(sns.violinplot, "Overall")

    sns.pairplot(footballers[['Overall', 'Potential', 'Value']])


    image.png

    fig, (axis1,axis2,axis3) = plt.subplots(1,3,figsize=(15,5))
    sns.countplot(x='Embarked', data=titanic_df, ax=axis1)
    sns.countplot(x='Survived', hue="Embarked", data=titanic_df, order=[1,0], ax=axis2)
    embark_perc = titanic_df[["Embarked", "Survived"]].groupby(['Embarked'],as_index=False).mean()
    sns.barplot(x='Embarked', y='Survived', data=embark_perc,order=['S','C','Q'],ax=axis3)


    相关文章

      网友评论

          本文标题:数据可视化(2)seaborn

          本文链接:https://www.haomeiwen.com/subject/dilqsftx.html