How to scale Seaborn's y-axis with a bar plot?

user124114 picture user124114 · Nov 19, 2014 · Viewed 38.1k times · Source

I'm using factorplot(kind="bar").

How do I scale the y-axis, for example with log-scale?

I tried tinkering with the plot's axes, but that always messed up the bar plot in one way or another, so please try your solution first to make sure it really works.

Answer

Michael Hall picture Michael Hall · Jun 26, 2017

Considering your question mentions barplot I thought I would add in a solution for that type of plot also as it differs from the factorplot in @Jules solution.

import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")

titanic = sns.load_dataset("titanic")

g = sns.barplot(x="class", y="survived", hue="sex",
                data=titanic, palette="muted")
g.set_yscale("log")

enter image description here