Home > Net >  How can I change the size of each graph in matplotlib using subplots
How can I change the size of each graph in matplotlib using subplots

Time:07-31

I have this code to graph a series, it is working but the size isn't enough:

    plt.subplot(1,3,1) 
    
    plt.bar(dias_creacion.index,dias_creacion)
    plt.xticks(np.arange(7),('Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'),rotation=45)
    plt.title('Días de creación')
    
    plt.subplot(1,3,2)
    
    plt.bar(dias_primera_conversion.index,dias_primera_conversion)
    plt.xticks(np.arange(7),('Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'),rotation=45)
    plt.title('Primeras conversiones')
    
    plt.subplot(1,3,3)
    
    plt.bar(dias_ultima_conversion.index,dias_ultima_conversion)
    plt.xticks(np.arange(7),('Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'),rotation=45)
    plt.title('Ultimas conversiones')
    
    plt.show()

I tried this:

plt.subplot(1,3,1) 
plt.figure(figsize=(10,10))
plt.bar(dias_creacion.index,dias_creacion)
plt.xticks(np.arange(7),('Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'),rotation=45)
plt.title('Días de creación') 

But it didn't work.

CodePudding user response:

plt.rcParams["figure.figsize"] = (20,10) is my go to to change figure size. Make sure to place it at the top of your graph code (even before plt.subplot(1,3,1))

  • Related