I have a figure saved as .png file by matplotlib of a matrix x:
fig = plt.figure(figsize=(1,1), dpi=100)
plt.imshow(x)
fig.savefig('filename.png')
This is the result, opened in Preview:
There is a white margin that I do not need, an my question is:
- how can I save the image in python without this margin?
P.S.: If I try the different solutions found in other posts, I don't get the result I need. For example the solutions:
fig.savefig('filename.png', bbox_inches='tight')
or
fig.savefig('filename.png', bbox_inches='tight', pad_inches=0)
give