Search code examples
pythonmatplotlibseaborn

Is there a way to specify subplots titles in FacetGrid seaborn?


I could not find a way to specify titles for subplots in FacetGrid in seaborn. Currently title is forced-set to be "grp="

master_df = pd.concat([source_school_small_uniform.assign(grp="taxi"),
                       source_school_large_uniform.assign(grp="bus")])

g = sns.FacetGrid(master_df, col="grp", hue="method", col_wrap=2, ...)

For the very least -- is there a way to remove "grp=" from the title?

enter image description here


Solution

  • I just had the same question and found this to work well: g.set_titles('{col_name}'). If you are dealing with a row x col plot, then you could use something along the lines of g.set_titles('{row_name}' ' | ' '{col_name}'). In addition, this post can be useful too Customizing annotation with Seaborn's FacetGrid.