首页 > 解决方案 > 将 Seaborn 轴转换为对数

问题描述

我正在使用 seaborn 将 pandas 数据框中的一些数据绘制为简单的箱线图。我想在 y 轴上使用对数刻度。有没有好的方法来做到这一点?

from matplotlib import style, pyplot as plt
import seaborn as sns
import pandas as pd

plt.figure()
sns.boxplot(x='Sample', y='Variants', data=plot_data)
plt.tick_params(labelbottom=True, bottom=False)
sns.despine(offset=10, trim=True, bottom=True)

我确实尝试过plt.set_yscale('log'),但我得到了这个错误:'module' object has no attribute 'set_yscale'

plt.yscale('log')给了我一个非常大的情节。

标签: pythonseaborn

解决方案


推荐阅读