pythonmatplotlibseabornrelplot

How to set axis label format to scientific format in seaborn relplot with facets when axes are not shared


I am creating a facet plot with the seaborn library with:

titanic = sns.load_dataset('titanic')
g = sns.relplot(data=titanic, x='fare', y='age', col='sex', row='survived', height=2, facet_kws=dict(sharex=False, sharey=False))
g.set_titles(row_template='{row_name}', col_template='{col_name}')
plt.ticklabel_format(axis='both', style='scientific', scilimits=(0, 0))

enter image description here

I would like ALL subplots to have scientific notation.

Using Seaborn version 0.11.2


Solution

  • g = sns.relplot(data=titanic, x='fare', y='age', col='sex', row='survived',
                    height=4, facet_kws=dict(sharex=True, sharey=True))
    g.set_titles(row_template='{row_name}', col_template='{col_name}')
    
    # iterate through all the axes
    for axes in g.axes.flat:
        axes.ticklabel_format(axis='both', style='scientific', scilimits=(0, 0))
    

    enter image description here