简体   繁体   English

Seaborn FacetGrid:使标签在每个子图中可见

[英]Seaborn FacetGrid: make labels visible in each subplot

I have built a Seaborn plot with the below data我用以下数据构建了一个 Seaborn plot

在此处输入图像描述

I made the below code to show the FacetGrid我制作了下面的代码来显示 FacetGrid

  def facetGridSales():
    grouped_sales_data=pd.read_excel("Random Sales Data.xlsx",sheet_name="Sheet1")
    g=sns.FacetGrid(data=grouped_sales_data,col='Location',col_wrap=4)
    g.map(sns.barplot,'Item','Total Sale Amount',order=['Junk','Stuff','Widgets','Things'])
    plt.savefig('CustomFacetGrid.jpg')

I have used col_wrap=4 to give 4 subplots in each line.我使用 col_wrap=4 在每行中给出 4 个子图。 在此处输入图像描述

My issue is that the labels ('Junk','Stuff','Widgets','Things) are not visible for the first row of subplots.我的问题是第一行子图的标签('Junk'、'Stuff'、'Widgets'、'Things)不可见。 Is there a way to increase the space between the rows of FacetGrid to make the first row labels visible?有没有办法增加 FacetGrid 行之间的空间以使第一行标签可见?

If you unshare the x-axis, it will be displayed on each of them.如果您取消共享 x 轴,它将显示在每个轴上。

g=sns.FacetGrid(data=df,col='Location',col_wrap=4, sharex=False)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM