epp2
epp2

Reputation: 31

Plotting a regression plot with a conditional Y axis

sns.regplot(x='rows', y='credit_scores', data=df1)

I have got this code currently in order to plot a regression line with my data where the Y axis 'credit_scores' ranges from 0 - 250. However, 4 of my plots are outliers which I do not want included on this plot. These outliers start from 75 on the Y axis. Therefore, is there any way for me to set a condition where the Y axis only selects all the data values which are below 75?

Is there also a way where I can change the colours of my regression line so that it is a different colour from my current plots which are in blue. So maybe have my plots in blue and the regression line in red.

Many Thanks!

Upvotes: 2

Views: 294

Answers (1)

Mighty Diffy
Mighty Diffy

Reputation: 98

new_df1 = df1[df1['credit_scores'] < 75]
sns.regplot(x='rows', y='credit_scores', data= new_df1 , color="red")

This code should do your work. Check:

Selecting rows based on conditions

Regplot Documentation

Upvotes: 1

Related Questions