Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started