私は次のことをしようとしています:
imshow()
matplotlib パッケージを使用してプロットを作成すると、matplotlib.image.AxesImage
matplotlib.image.AxesImage
に変換PIL.ImageTk.PhotoImage
- これ
PIL.ImageTk.PhotoImage
を TkInter キャンバスの画像として使用する
画像を保存せずに上記を達成するにはどうすればよいですか?
投稿を参照した後、次のコードでデータを直接色分けしようとしました:
from Tkinter import *
from PIL import ImageTk,Image
import numpy as np
from pylab import cm
root=Tk()
canvas = Canvas(root)
canvas.pack(expand = YES, fill = BOTH)
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
myarray = np.sin(x) + np.cos(y)
image1 = Image.fromarray(np.uint8(cm.gist_earth(myarray)*255))
test = canvas.create_image(10,10,image = image1)
#canvas.itemconfig(test, image=nextimage)
mainloop()
上記のコードはエラーを返します
TclError: image "<PIL.Image.Image image mode=RGBA size=120x100 at 0x2DC01E8>" doesn't exist
何が問題なのですか?