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

后端 未结 3 1670
星月不相逢
星月不相逢 2020-12-09 15:55

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 al

3条回答
  •  攒了一身酷
    2020-12-09 16:12

    You can use Matplotlib commands after calling factorplot. For example:

    import seaborn as sns
    import matplotlib.pyplot as plt
    sns.set(style="whitegrid")
    
    titanic = sns.load_dataset("titanic")
    
    g = sns.factorplot("class", "survived", "sex",
                       data=titanic, kind="bar",
                       size=6, palette="muted", legend=False)
    g.fig.get_axes()[0].set_yscale('log')
    plt.show()
    

    enter image description here

提交回复
热议问题