x轴向右移动,不确定原因。我使用过plt.xlim(left=0)
,但是即使没有负值,分布线仍然来自负值?
代码如下:
plt.figure(figsize = (10,10))
# vals will be used to store the index of all the loan_type that equal 'TR'
vals = []
my_vals = []
for x in range(len(df['LOAN_TYPE'])):
if (df['LOAN_TYPE'][x] == 'TR' or df['LOAN_TYPE'][x] == 'TOFR') and df['PAY_FREQUENCY'][x] == 'M':
vals = df['LOAN_TYPE'].index[x]
my_vals.append(vals)
sns.distplot(df['# Payments Made'][my_vals],bins = 60)
#plt.xticks(np.arange(min(df['# Payments Made'][my_vals]),max(df['# Payments Made'][my_vals])+1,1))
plt.axvline(np.mean(df['# Payments Made'][my_vals]), color="r", linestyle="--");