I have plotted matplotlib.pyplot
plot. I have already removed the axes and title of the plot such that in jupyter notebook it looks like an image.
But I need to save that plot as an image to my local disk with required pixel resolution. In my case it's 40 X 98.
I have tried plt.savefig
but I can't get the measurements accurately. I have provided my code snippet below. (spectrum) is my 2D array which is to be plotted as a fucntion of x and y axes.
spect = 20 * np.log10(spectrum)
fig, ax = plt.subplots(figsize=(1,1))
ax = sns.heatmap(spect,cmap='viridis',cbar=False,xticklabels=False, yticklabels=False)
ax.invert_yaxis()
plt.savefig('sample.png',bbox_inches = 'tight', pad_inches = 0)