I am using the following code to calculate the frequency or the MFCC coefficients of a wavelet signal. When I have calculated my signals (frequency over time) in 2D numpy arrays I am trying to store it locally into a .png images. I am trying to do so with two different possible ways. Firstly, by using:
matplotlib.image.imsave("my_img.png", filter_banks)
That leads to:
and the second way using librosa tool:
import librosa.display
from matplotlib import cm
fig = plt.figure(figsize=(..., ...), dpi=1)
librosa.display.specshow(filter_banks.T, cmap=cm.jet)
plt.tight_layout()
plt.savefig("_plot_static_conv.png")
plt.show()
and the result is look like:
My issue is that I am having some white margin over the image which are not desired. How can I have the same size also in the second case and avoid the white margin over the image that I guess is caused by the plt.figure?
EDIT: I tried to use the answer from the following post but it did not solve my issue.