【发布时间】:2016-02-21 15:22:44
【问题描述】:
我正在使用 pandas 0.17.0 版、matplotlib 1.4.3 版和 seaborn 0.6.0 版来创建箱线图。我想要浮点表示法中的 x 轴上的所有值。目前,两个最小值(0,00001 和 0,00005)以科学计数法格式化。
这是我用来绘制图像的代码:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.read_csv("resultsFinal2.csv")
boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"))
plt.show()
按照How to prevent numbers being changed to exponential form in Python matplotlib figure 的建议,我试过了:
boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"))
ax = plt.gca()
ax.get_xaxis().get_major_formatter().set_scientific(False)
导致:
plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
AttributeError: 'FixedFormatter' object has no attribute 'set_useOffset'
Seaborn Boxplot 文档说,我可以传递一个 Axes 对象来绘制绘图。所以我尝试创建一个禁用科学计数法的轴并将其传递给 sns.boxplot:
ax1 = plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"), ax=ax1)
那也没用。谁能告诉我怎么做?
【问题讨论】:
-
您的链接已损坏。另外,请指定您使用的 matplotlib 版本(我的错误信息与您的不同)
标签: python pandas matplotlib seaborn