MNE version 1.1.1
Google Colab
I want to get rid of white spaces from this plot. The plot is from mne
library example here. I only want to data in the box and nothing else. I converted the plot to image like this:
def get_img_from_fig(fig, dpi=180):
buf = io.BytesIO()
fig.savefig(buf, format="png", dpi=fig.dpi)
buf.seek(0)
img_arr = np.frombuffer(buf.getvalue(), dtype=np.uint8)
buf.close()
img = cv2.imdecode(img_arr, 1)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
return img
I tried a lot of things including this:
plt.axis('off')
plt.imshow(img_orig_2)
plt.savefig('test.png', bbox_inches='tight',pad_inches = 0, dpi = 180)
plt.show()
I also went into the library to get the data but it still gives the plot with white spaces. What should I do besides manually cropping or setting the aspect ratio?