python - 如何对seaborn relplot的轴使用对数刻度?

标签 python matplotlib seaborn

我尝试使用对数缩放轴绘制 relplot。
利用以前的answers , 我试过:

import matplotlib.pyplot as plt
import seaborn as sns

f, ax = plt.subplots(figsize=(7, 7))
ax.set(xscale="log", yscale="log")

tips = sns.load_dataset("tips")
sns.relplot(x="total_bill", y="tip", hue='smoker', data=tips)
plt.show()
然而,结果中的轴没有改变。
enter image description here
我该如何补救?

最佳答案

对于 sns.relplot您可以按如下方式设置比例:

g = sns.relplot(...)
g.set(xscale="log")
g.set(yscale="log")

关于python - 如何对seaborn relplot的轴使用对数刻度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63873363/

相关文章:

python - 在 matplotlib 中禁用 imshow colorbar 的科学记数法

python - Seaborn 通过多个 groupby 绘制 pandas 数据框

python - "from keras.utils import to_categorical"中的错误

python - Pandas :用列最大值替换列中的所有值

python - 用变音符号编码阿拉伯字母(如果存在)

python - matplotlib 修改 colormap 以白色为零

python - 如何在 Seaborn 的热图轴上表达类

python - 将相关系数添加到seaborn散点图

python - 在多个 Seaborn Stripplot 中可视化样本大小

python - 如何返回列表项的索引