I am creating matplotlib plots using data processed by a function. I would like to plot the data and compare the plot to another plot, albeit on different scales. I am using image hash library but unable to get the hash of an image without saving it first.
import hashlib
import numpy as np
import matplotlib.pyplot as plt
import imagehash
from io import BytesIO
X = np.linspace(0,100,1000)
Y = np.sin(0.5*X)
plt.plot(X,Y)
buffer1 = BytesIO()
plt.savefig(buffer1, format='png')
#canvas = plt.gcf().canvas
#canvas.draw()
#new_hash = hashlib.sha1(np.array(canvas.buffer_rgba())).hexdigest()
new_hash = imagehash.whash(buffer1)
print(str(new_hash))
plt.cla()
How can I do this. I saw a thread that uses hash lib but I would like to use image hash library.