如何在Seaborn/Matplotlib中消除factorplot Y轴的科学计数法?
为了在Seaborn/Matplotlib中消除因子图的Y轴上的科学计数法,我们可以使用 ticklabel_format()中的style=”plain” 方法。
步骤
- 设置图形大小并调整子图之间和周围的填充。
-
使用键col1和col2创建一个数据框。
-
factorplot()已重命名为catplot()。
-
使用 ticklabel_format()中的style=”plain” 方法消除科学计数法。
-
使用 show() 方法显示图形。
更多Matplotlib教程,请访问:Matplotlib教程
示例
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
plt.rcParams["figure.figsize"] =[7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
df = pd.DataFrame({"col1": [1, 3, 5, 7, 1], "col2": [1, 5, 7, 9, 1]})
sns.catplot(y="col1", x="col2", kind='bar', data=df, label="Total", height=3.5)
plt.ticklabel_format(style='plain', axis='y')
plt.show()