代码给我一个错误,说没有图像,有什么有用的建议吗?它说image1不是图像,正如你所看到的,这是不正确的,因为它是在代码运行时创建的。
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from tkinter import *
from PIL import ImageTk, Image
import os
weatherdata = pd.read_csv('london_weather.csv')
#graph the data
sns.pairplot(weatherdata,
x_vars="pressure",
y_vars="precipitation",
hue="mean_temp",
aspect=3,
height=3)
plt.savefig('image1.png')
#All the code above is working however i cannot output the image, which is really annoying.
root = Tk()
img = ImageTk.PhotoImage(Image.open("image1.png"))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()
1条答案
按热度按时间5f0d552i1#
您可以使用变量,然后保存: