Issue
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))
I would like ALL subplots to have scientific notation.
Using Seaborn version 0.11.2
Solution
- Since the axes are not shared, the format can be set by iterating through each axes.
- This answer shows how to set the tick label format when x and y are shared.
- Tested in
python 3.10
,matplotlib 3.5.1
,seaborn 0.11.2
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))
Answered By - Trenton McKinney
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.