I have used plt.plot(plot1['x'], plot1['y'])
to produce a plot from my "plot1" dataset.
I want to get a file like object from this plot how can I get it done?
Here is the full code:
I have used plt.plot(plot1['x'], plot1['y'])
to produce a plot from my "plot1" dataset.
I want to get a file like object from this plot how can I get it done?
Here is the full code:
So, it looks like you want to save your plot as a format that can be copied in instant messaging:
import io, base64
picture = io.BytesIO()
plt.savefig(picture, format='png')
picture.seek(0)
picture_b64 = base64.b64encode(picture.read())
Solution,
import io
buf = io.BytesIO()
plt.savefig(buf, format='png')
buf.seek(0)
file = discord.File(buf, "image.png")
buf.close()
return file # or do anything with the file