How can I create a histogram where I can display Age in respect to TimeToPayInDays?
I can't see in the docs any y
parameter for the y axis.
I want to see if age influences the time it takes to pay off a loan.
#check if age influences how fast men pay what they owe to bank
print(malesSample['Age'].min())
print(malesSample['Age'].max())
# Creating histogram
fig, ax = plt.subplots(figsize =(10, 7))
ax.hist(malesSample['Age'], bins = malesSample['TimeToPayInDays'])
# Show plot
plt.show()
**csv DataSet**
Age TimeToPayInDays
22 4
24 5
39 64
17 27
36 12
51 85
42 19
Edit
As per Sergey's suggestion, I have a made a scatter plot.
print(malesSample['Age'].min()) #21.0
print(malesSample['Age'].max()) #51.0
print(feamalesSample['Age'].min()) #23.0
print(feamalesSample['Age'].max()) #44.0
age_Range = [20,25,30,35,40,45,50,55]
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.scatter(x=malesSample['Paid_Off_In_Days'],y=malesSample['Age'], color='blue')
ax.set_xlabel('Paid Off In_Days')
ax.set_ylabel('Age')
ax.set_title('How does age influences time to pay off loan?')
plt.show()