I am trying to save sns matplotlib output as jpg file and reopen it with cv2.
but i am facing distinct data loss, would someone help me to resolve, i tried in several savefig options and documentations.
sample code
import pandas as pd
import numpy as np
import cv2
import seaborn as sns
import matplotlib.pyplot as plt
by_c = None
fig = plt.Figure(figsize=(5, 4), dpi=100)
g = sns.FacetGrid(pd.DataFrame(np.random.random(10)*150, columns=['col']), col=None, row=None, height=3.5, aspect=1)
g.map_dataframe(sns.histplot, x='col')
plt.title('col'+' - '+str(by_c)+'-', fontsize=12)
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.savefig('temp.png')
plt.show()
Out:
Saved picture example of 'temp.png'
reopening image
im = cv2.imread('temp.png')
plt.imshow(im)
Out1: Image title and lables sliced bit, i am not sure how else i can save it. Would someone please help to resolve it