在Seaborn中组合条形图和线形图

问题描述

我试图在此处合并两个不同的图,一个是条形图,另一个是线形图

我有以下代码

plt.figure(figsize=(30,7))

# Plot 1: Line chart for loan distribution over years
plt.subplot(1,4,1)
cx = loan_data.groupby('issue_d_year').loan_amnt.count().plot(kind='line',fontsize=7)
for p in cx.patches:
    cx.annotate(format(p.get_height(),'.2f'),(p.get_x() + p.get_width() / 2.,p.get_height()),ha = 'center',va = 'center',xytext = (0,10),textcoords = 'offset points')
plt.title("Number of Loans over years",weight ='bold')
plt.ylabel("Count of loan amount")
plt.xlabel("Loans funded across years")


# Plot 2: bar chart for loan distribution over years
plt.subplot(1,2)
cxs = loan_data.groupby('issue_d_year').loan_amnt.count().plot(kind='bar',fontsize=7)
for p in cxs.patches:
    cxs.annotate(format(p.get_height(),weight ='bold')
plt.ylabel("Count of loan amount")
plt.xlabel("Loans funded across years")

plt.figure(figsize=(70,7))

# Plot 3: Line chart for loan distribution over months
plt.subplot(1,3)
dx = loan_data.groupby('issue_d_month').loan_amnt.count().plot(kind='line',fontsize=7)
for p in dx.patches:
    dx.annotate(format(p.get_height(),textcoords = 'offset points')
plt.title("Number of Loans over months",weight ='bold')
plt.ylabel("Count of loan amount")
plt.xlabel("Loans funded across months")


# Plot 4: Bar chart for loan distribution over months
plt.subplot(1,4)
dxs = loan_data.groupby('issue_d_month').loan_amnt.count().plot(kind='bar',fontsize=7)
for p in dxs.patches:
    dxs.annotate(format(p.get_height(),weight ='bold')
plt.ylabel("Count of loan amount")
plt.xlabel("Loans funded across months")
plt.show()

输出

enter image description here

有没有办法我可以将前2个图表合并为一个,将底部2个图表合并为一个,并用红色将线涂成红色

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...