Search code examples
pythonseaborndata-visualizationbar-chartfacet-grid

Seaborn FacetGrid: make labels visible in each subplot


I have built a Seaborn plot with the below data

enter image description here

I made the below code to show the 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. enter image description here

My issue is that the labels ('Junk','Stuff','Widgets','Things) are not visible for the first row of subplots. Is there a way to increase the space between the rows of FacetGrid to make the first row labels visible ?


Solution

  • If you unshare the x-axis, it will be displayed on each of them.

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

    enter image description here