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
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.
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.
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 sns
import matplotlib.pyplot as plt
plot = 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 sns
import matplotlib.pyplot as plt
plot = 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.
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.
. ?? 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
I'm not familiar with seaborn, but I'd guess from the error that there's at least one text value inside the
Synergy_percentfield 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.I'm not familiar with seaborn, but I'd guess from the error that there's at least one text value inside the
Synergy_percentfield 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
VOTE
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
seabornneeds to know where columns arexand which arey... within the data frame . This information appears missing and the OP usedy='title', x='titlewithout reference to the dataframe. I'm pretty certain thats the bug here.Alternative, which seems more what the OP wants ...
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
I don't know beyond, e.g. imposing percentile ranges onto a boxplot.
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
seabornneeds to know where columns arexand which arey... within the data frame . This information appears missing and the OP usedy='title', x='titlewithout reference to the dataframe. I'm pretty certain thats the bug here.Alternative, which seems more what the OP wants ...
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
I don't know beyond, e.g. imposing percentile ranges onto a boxplot.
More
VOTE
VOTE
VOTE
VOTE
VOTE
VOTE