Código Python para figuras

Código para configurar el tamaño de letra en los gráficos de python
#%% Celda para configurar tipografía
 
SMALL_SIZE = 10
MEDIUM_SIZE = 15
BIGGER_SIZE = 20

 

plt.rc('font', size=SMALL_SIZE)          # controls default text sizes
plt.rc('axes', titlesize=MEDIUM_SIZE)     # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=MEDIUM_SIZE)    # fontsize of the tick labels
plt.rc('ytick', labelsize=MEDIUM_SIZE)    # fontsize of the tick labels
plt.rc('legend', fontsize=MEDIUM_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
 
#%% Celda para crear figura
fig,ax1 =plt.subplots(figsize=(8,5),constrained_layout=True) #con figsize me defino la proporción de los ejes
plt.plot(x,y)
# con las siguientes lineas uno puede agregar mallado al gráfico
ax1.grid(which = "major", linewidth = 1)
ax1.grid(which = "minor", linewidth = 0.2)
ax1.minorticks_on()
 
# Para guardar la figura 
plt.savefig('carpeta\nombredelarchivo.png',dpi=350,transparent=True)
#también se pueden guardar en pdf o en svg
plt.show()