I have code:
def get_image_array(data):
fig = plt.figure(figsize=(1.5, 1.5), dpi=100)
plt.plot(data, '-o', c='r')
plt.axis('off')
fig.canvas.draw()
img_arr = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
img_arr = img_arr.reshape(fig.canvas.get_width_height()[::-1] + (3,)).astype(np.float32)
img_arr = img_arr[None, :]
plt.close()
return img_arr
where I create figure with figure size 150x150 (RGB), convert it to numpy array for using in CNN model. I launch it on FullHD monitor and it works, but it doesn't work on 2k, 4k monitors. The erros is:
ValueError: cannot reshape array of size 270000 into shape (150,150,3)
How can I create figure with figure size 150x150 for different types of resolution?