Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions