I have a pandas dataframe with multiple columns I am trying to plot the column "Score" (on x axis) with another column called "interest rate". I am using the following commands:
box_plot=sns.boxplot(x=list(Dataframe['Score']),y=list(Dataframe['Interest.Rate']),data=Dataframe)
box_plot.set(xlabel='FICO Score',ylabel='Interest Rate')
This works fine and it create a boxplot with appropriate axes. Seems like I have to pass the variables as list in boxplot function. Maybe there is better way to do it.
The problem is x axis labels are too crowded and are not readable so I don't want them all too print, only some of them for better readability.
I have tried multiple options with xticks and xticklabel functions but none of them seem to work.
you could do simply this:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('your_data.csv', index_col=0)
sns.boxplot(
x='Score',
y='Interest.Rate',
data=data
).set(
xlabel='FICO Score',
ylabel='Interest Rate'
)
plt.show()
try it this way:
box_plot=sns.boxplot(x='Score', y='Interest.Rate',data=Dataframe)
instead of converting pandas series to lists
if you need help with the X axis please post sample data set which helps to reproduce your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With