Paste
Copy
Cut
Options
non sub cta modal sparkle

¡Tu solución está lista!

Mejorada con IA, nuestra ayuda de expertos desglosó tu problema en una solución confiable y fácil de entender.

Mira la respuesta
  • Pregunta: #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 =

    #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()
  • Chegg Logo
    Esta es la mejor manera de resolver el problema.
    Solución