4

I'm using pandas version 0.17.0 , matplotlib version 1.4.3 and seaborn version 0.6.0 to create a boxplot. I want all values on the x-axis in float notation. Currently the two smallest values (0,00001 and 0,00005) are formatted in scientific notation.

Here's the code I use to plot the image:

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

As suggested in How to prevent numbers being changed to exponential form in Python matplotlib figure, i tried:

boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"))
ax = plt.gca()
ax.get_xaxis().get_major_formatter().set_scientific(False)

resulting in:

    plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
AttributeError: 'FixedFormatter' object has no attribute 'set_useOffset'

Seaborn Boxplot documentation says, I can pass an Axes object to draw the plot onto. So I tried to create an axis with scientific notation disabled and passed it to 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)

That didn't work either. Can someone tell me how to do it?

Community
  • 1
  • 1
Osvald Laurits
  • 1,228
  • 2
  • 17
  • 32
  • 1
    Your link is broken. Also, please specify which matplotlib version you use (my error message is different than yours) – Boris Gorelik Nov 19 '15 at 13:41

1 Answers1

1

This might be an ugly solution, but it works, so who cares

fig, ax = plt.subplots(1, 1)
boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"), ax=ax)
labels = ['%.5f' % float(t.get_text()) for t in ax.get_xticklabels()]
ax.set_xticklabels(labels)
Boris Gorelik
  • 29,945
  • 39
  • 128
  • 170