0

I have X and Y values, I want to convert them to an image and then get the image data. How can I do that process in memory. I have tried using matplotlib to plot the values and save them.

app = QApplication(sys.argv)
screen = app.screens()[0]
dpi = screen.physicalDotsPerInch()
px = 1 / plt.rcParams['figure.dpi']
plt.figure(figsize=(40*px, 40*px))
plt.plot(x.index, values)
plt.axis('off')
plt.savefig("S:\\MlData\\BlData\\imagetests\\test.png", pad_inches = 0)

this saves the image but with white margins which I cant remove no matter what I have tried. How can I load the data and get the image Matrix and how can I do this without saving the image and reading it from the dist?

Thanks

Amit

Amit Raz
  • 5,370
  • 8
  • 36
  • 63
  • 1
    Instead of `plt.plot(x.index, values)`, have you tried `plt.imshow([x.index, values])`? – Arne Jan 19 '22 at 16:26
  • 1
    Seems like you also want to remove the white background. See [this](https://stackoverflow.com/questions/15857647/how-to-export-plots-from-matplotlib-with-transparent-background) answer for how to do that. Simply add the argument ```transparent = True``` to the ```plg.savefig()``` function. – nikost Jan 19 '22 at 16:30

0 Answers0