Draw a horizontal line line at specific position/annotate a Facetgrid in seaborn

前端 未结 4 758
北恋
北恋 2021-02-05 07:07

A have produced a boxplot with Facetgrid in seaborn the following way

# Import the dataset
tips = sns.load_dataset(\"tips\")

# Plot using Facegrid, separated by         


        
4条回答
  •  再見小時候
    2021-02-05 08:04

    Just add to the top answer, if you want do the same thing with figures in cols.

    g = sns.FacetGrid(df_long, col="variable", size=5, aspect=1.5,col_wrap=1,sharey=False)
    # df_long is a long table with 3 variables
    g.map(sns.boxplot, "label", "value", palette='Set2')
    g.axes[0].axhline(1, ls='--',c='r')
    g.axes[1].axhline(1, ls='--',c='r')
    g.axes[2].axhline(0.5, ls='--',c='r')
    g.map(plt.xticks, rotation=70) 
    plt.show()
    

    result

提交回复
热议问题