Question: #Create dataframes for recession and non - recession period rec _ data = df [ df [ ' Recession ' ] = = 1 ]
#Create dataframes for recession and nonrecession period
recdata dfdfRecession
nonrecdata dfdfRecession
#Figure
figpltfigurefigsize
#Create different axes for subploting
ax fig.addsubplot # add subplot row, columns, first plot
ax fig.addsubplot # add subplot row, columns, second plot
#pltsubplot
snslineplotx'Year', yGDP datarecdata, label'Recession', axax
axsetxlabelYear
axsetylabelGDP
axsettitleGDP Variation during Recession Period'
#pltsubplot
snslineplotx y data labelax
axsetxlabel
axsetylabel
axsettitle
plttightlayout
pltshow
#Alternatively
#Using subplot
pltfigurefigsize
#subplot
pltsubplot
snslineplotx y data label
pltxlabel
pltylabel
pltlegend
#subplot
pltsubplot
snslineplotx y data label
pltxlabel
pltylabel
pltlegend
plttightlayout
pltshow
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
