Question: #Create dataframes for recession and non - recession period rec _ data = df [ df [ ' Recession ' ] = = 1 ]

#Create dataframes for recession and non-recession period
rec_data = df[df['Recession']==1]
non_rec_data = df[df['Recession']==0]
#Figure
fig=plt.figure(figsize=(12,6))
#Create different axes for subploting
ax0= fig.add_subplot(1,2,1) # add subplot 1(1 row, 2 columns, first plot)
ax1= fig.add_subplot(...,...,...) # add subplot 2(1 row, 2 columns, second plot).
#plt.subplot(1,2,1)
sns.lineplot(x='Year', y='GDP', data=rec_data, label='Recession', ax=ax0)
ax0.set_xlabel('Year')
ax0.set_ylabel('GDP')
ax0.set_title('GDP Variation during Recession Period')
#plt.subplot(1,2,2)
sns.lineplot(x='......', y='......', data=........, label='.........',ax=...)
ax1.set_xlabel('.....')
ax1.set_ylabel('.......')
ax1.set_title('..........')
plt.tight_layout()
plt.show()
#------------------------------------------------Alternatively--------------
#Using subplot()
plt.figure(figsize=(............,..........))
#subplot 1
plt.subplot(1,2,1)
sns.lineplot(x='.........', y='......', data=.........., label='......')
plt.xlabel('.......')
plt.ylabel('..........')
plt.legend()
#subplot 1
plt.subplot(1,2,2)
sns.lineplot(x='.........', y='......', data=.........., label='......')
plt.xlabel('.......')
plt.ylabel('..........')
plt.legend()
plt.tight_layout()
plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!