如何使用条形图缩放 Seaborn 的 y 轴? [英] How to scale Seaborn's y-axis with a bar plot?

查看:53
本文介绍了如何使用条形图缩放 Seaborn 的 y 轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 factorplot(kind="bar").

如何缩放 y 轴,例如使用对数缩放?

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.

推荐答案

考虑到你的问题提到了 barplot 我想我也会为这种类型的情节添加一个解决方案,因为它与 factorplot 在@Jules 解决方案中.

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")

这篇关于如何使用条形图缩放 Seaborn 的 y 轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆