plt.savefig() removes the blank area, the background is transparent

First, the background transparency parameter `plt.savefig('output_pltsave.png', format='png', bbox_inches='tight', dpi=300, transparent=True)
Note: The dpi here is only 150, which will cause the blank area to be too large

plt.savefig('output_pltsave.png', format='png', bbox_inches='tight', dpi=150, transparent=True)

Insert picture description here

plt.savefig('output_pltsave.png', format='png', bbox_inches='tight', dpi=300, transparent=True)

The effect after setting dip to 300 (the specific value is adjusted according to yourself).
Insert picture description here

Guess you like

Origin blog.csdn.net/Caiqiudan/article/details/112796750