So I'm following along this tutorial: https://www.analyticsvidhya.com/blog/2016/01/complete-tutorial-learn-data-science-python-scratch-2/
And I'm encountering an issue that I am having a hard time grasping. My goal is to output two subplots side-by-side, the left feeding from a temp1 dataframe, and the right from temp2 table:
temp1:
Frequency Table for Credit History:
0.0 89
1.0 475
Name: Credit_History, dtype: int64
temp2:
Probility of getting loan for each Credit History class:
Loan_Status
Credit_History
0.0 0.078652
1.0 0.795789
This is the code block:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,4))
ax1 = fig.add_subplot(121)
ax1.set_xlabel('Credit_History')
ax1.set_ylabel('Count of Applicants')
ax1.set_title("Applicants by Credit_History")
temp1.plot(kind='bar')
ax2 = fig.add_subplot(122)
temp2.plot(kind = 'bar')
ax2.set_xlabel('Credit_History')
ax2.set_ylabel('Probability of getting loan')
ax2.set_title("Probability of getting loan by credit history")
This is the output I'm getting:
I was expecting to just have two subplots side-by-side, but my intended second subplot on the right is empty, and instead the temp2 chart is outputted in a third plot below it.
Any ideas? I'm finding matplotlib to be quite unintuitive so any advice is appreciated!
EDIT: I tried tinkering with this codeblock instead:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,4))
ax1 = fig.add_subplot(121)
ax1.set_xlabel('Credit_History')
ax1.set_ylabel('Count of Applicants')
ax1.set_title("Applicants by Credit_History")
temp1.plot(kind='bar')
ax2 = fig.add_subplot(122)
#temp2.plot(kind = 'bar')
ax2.plot(temp2) # new attempt
ax2.set_xlabel('Credit_History')
ax2.set_ylabel('Probability of getting loan')
ax2.set_title("Probability of getting loan by credit history")
and that gets me closer to the desired format, only I want a bar chart not line