admin管理员组

文章数量:1334375

I recently got the warning MatplotlibDeprecationWarning: savefig() got unexpected keyword argument "figsize" which is no longer supported as of 3.3 and will become an error in 3.6 for the command

plt.savefig("Beta-transition-log_ME.png",format='png',dpi=300,bbox_inches='tight',transparent=True,figsize=(16,14))

This is hard since basically every tutorial and slack overflow question about how to tune the size of a matplotlib plot mentions using figsize() as a method to do so. In the light of this being depreciated, what is the solution?

This is my entire code block with the error:

plt.errorbar(Beta, ME_avg, yerr=error, fmt="o")
plt.ylabel('Density averaged kinetic energy ',fontsize=11)
plt.xlabel('AV-normalized cooling time',fontsize=12)
plt.title('Space & time-averaged final saturated energy')
plt.axhline(avg_u,color='red',label = 'Isothermal')
plt.legend()
plt.loglog()
plt.savefig("Beta-transition-log_ME.png",format='png',dpi=300,bbox_inches='tight',transparent=True,figsize=(16,14))
plt.show()

I recently got the warning MatplotlibDeprecationWarning: savefig() got unexpected keyword argument "figsize" which is no longer supported as of 3.3 and will become an error in 3.6 for the command

plt.savefig("Beta-transition-log_ME.png",format='png',dpi=300,bbox_inches='tight',transparent=True,figsize=(16,14))

This is hard since basically every tutorial and slack overflow question about how to tune the size of a matplotlib plot mentions using figsize() as a method to do so. In the light of this being depreciated, what is the solution?

This is my entire code block with the error:

plt.errorbar(Beta, ME_avg, yerr=error, fmt="o")
plt.ylabel('Density averaged kinetic energy ',fontsize=11)
plt.xlabel('AV-normalized cooling time',fontsize=12)
plt.title('Space & time-averaged final saturated energy')
plt.axhline(avg_u,color='red',label = 'Isothermal')
plt.legend()
plt.loglog()
plt.savefig("Beta-transition-log_ME.png",format='png',dpi=300,bbox_inches='tight',transparent=True,figsize=(16,14))
plt.show()
Share Improve this question asked Nov 20, 2024 at 16:58 Pundarikaksha KavipurapuPundarikaksha Kavipurapu 615 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

Set the figure size when creating the figure:

plt.figure(figsize=(16, 14))

Save without the figsize argument:

plt.savefig("Beta-transition-log_ME.png", format='png', dpi=300, bbox_inches='tight', transparent=True)

本文标签: