I am trying to plot a box plot with seaborn with the following code
plot = sns.boxplot(
y='Min PPI distance',
x='Synergy_percent',
color='white',
orient="h",
data=synergy_df
)
plot.set(
xlabel='Synergy (%)',
ylabel='Min. distance',
);
The data synergy_df looks like
Combination Min PPI distance Synergy_percent
0 1003- Camptothecin & 1011- Navitoclax 2.0 22.2
1 1003- Camptothecin & 1017- Olaparib 2.0 6.4
2 1003- Camptothecin & 1022- AZD7762 2.0 40.4
3 1003- Camptothecin & 1025- SB216763 3.0 2.1
4 1003- Camptothecin & 1032- Afatinib 3.0 2.2
After running the above code I am getting the error
TypeError: Horizontal orientation requires numeric `x` variable.
I want to add that Synergy_percent column has many zero values and about 1500 rows; I haven't tried it with a smaller number of rows.
I think the reason for the error is the wide range in the synergy_percent values. The range is between 0 to 86.7. If I use xlim here what range should I use to divide the x-axis in 4 quarters (0-25-50-100)?
Background Seaborn is a Python library for more complex graph plotting than the commonly used matplotlib and is often used for boxplots and heatmaps usually using a pandas dataframe. The official documents are described here.
dodge=True. ?? 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 aboutpandasfiltering and would be outside seaborn. I'm pretty certain you just need a simple tweak withinboxplotmethod. However, beyond thedodgetrick I dunno, butdodgedoes clean stuff up. – M__ Apr 18 '22 at 14:27data=Xdoesn't have the same effect in seaborn as it does in R. – gringer Apr 19 '22 at 03:19