Home > Community > Error in seaborn plot Horizontal orientation requires numeric `x` variable
Upvote

20

Downvote
+ Bioinformatics
+ Biochemistry
+ Python
+ Graphs
Posted by
King Hailu

Error in seaborn plot Horizontal orientation requires numeric `x` variable

Basecrete Global??  Follow

I'm not familiar with seaborn, but I'd guess from the error that there's at least one text value inside the Synergy_percent field that is encouraging the rest of the values to text. Either that, or spaces in the input file are messing up the parsing of the columns.

More

Upvote

VOTE

Downvote
Abdulalah T. Mohammed  Follow

Very quickly because I'm not around.

I think I know what's going on, but don't have enough time to figure the df. The key thing is seaborn needs to know where columns are x and which are y ... within the data frame . This information appears missing and the OP used y='title', x='title without reference to the dataframe. I'm pretty certain thats the bug here.

import seaborn as snsimport matplotlib.pyplot as pltplot = sns.boxplot(    color='white',    y=synergy_df["Synergy_percent"],     x=synergy_df["Min PPI distance"] );plt.show()

Alternative, which seems more what the OP wants ...

import seaborn as snsimport matplotlib.pyplot as pltplot = sns.boxplot(    color='white',    # use your orientation command here    x=synergy_df["Synergy_percent"],     y=synergy_df["Min PPI distance"] );plt.show()

Blurb Normally the x-axis is the discrete boundary whilst the y-axis is continuous. In you example the x-axis feels like the continuous variable and you are producing a rotated boxplot - thats perfectly fine and seabourn will do that however its good to get it working first before rotating the axes.

Final The orientation of the dataframe might possibly be an issue, not sure unless its tried.


If there's a formatting issue the only trick I know is

 plot = sis.boxplot( .... # same old dodge=True, );

I don't know beyond, e.g. imposing percentile ranges onto a boxplot.

More

Upvote

VOTE

Downvote
Emil Bode  Follow
Good to know; I guess that means More
Upvote

VOTE

Downvote
Ivan Bangov  Follow
filtering and would be outside seaborn. I'm pretty certain you just need a simple tweak within More
Upvote

VOTE

Downvote
Edward Cramer  Follow
. ?? What I think you want is to tweak the 'box and whiskers' of the boxplot - which I'd have to look up. The other possibility (which I don't think you want) is to make 4 boxplots within the range specified. This is last point is about More
Upvote

VOTE

Downvote
Joseph o'Loughlin  Follow
data=XMore
Upvote

VOTE

Downvote
Georges Kawkabany  Follow
dodge=TrueMore
Upvote

VOTE

Downvote
more replies