简体   繁体   中英

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

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.

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) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM