new_loans['loan_condition'].head()
0 Good Loan
1 Bad Loan
2 Good Loan
3 Good Loan
4 Good Loan
Name: loan_condition, dtype: object
f, ax = plt.subplots(1, 2, figsize=(16,8))
colors = ["#3791D7", "#D72626"]
labels ="Good Loans", "Bad Loans"
plt.suptitle('Information on Loan Conditions', fontsize=20)
new_loans["loan_condition"].value_counts().plot.pie(explode=[0,0.25], autopct='%1.2f%%', ax=ax[0], shadow=True, colors=colors,
labels=labels, fontsize=12, startangle=70)
上面生成了这些图:
如何摆脱右侧的空白区域?
我尝试了plt.subplots(1,1, figsize=(16,8)
,但遇到了以下错误:TypeError: 'AxesSubplot' object does not support indexing
我也将ax=ax[0]
替换为ax
,但出现以下错误:numpy.ndarray' object has no attribute 'get_figure'
当我在Squeeze = False
中使用plt.subplots
时,代码仍然无法正常工作。