Python, Seaborn FacetGrid change titles

前端 未结 2 1995
轮回少年
轮回少年 2020-12-17 15:27

I am trying to create a FacetGrid in Seaborn

My code is currently:

g = sns.FacetGrid(df_reduced, col=\"ActualExternal\", margin_titles=True)
bins = n         


        
2条回答
  •  悲哀的现实
    2020-12-17 15:56

    You can access the axes of a FacetGrid (g = sns.FacetGrid(...)) via g.axes. With that you are free to use any matplotlib method you like to tweak the plot.

    Change titles:

    axes = g.axes.flatten()
    axes[0].set_title("Internal")
    axes[1].set_title("External")
    

    Change labels:

    axes = g.axes.flatten()
    axes[0].set_ylabel("Number of Defects")
    for ax in axes:
        ax.set_xlabel("Percentage Depth")
    

    Note that I prefer those above the FacetGrid's internal g.set_axis_labels and set_titles methods, because it makes it more obvious which axes is to be labelled.

提交回复
热议问题