We have some discussions about embedding a matplotlib with slider in tkinter
Python: Embed a matplotlib plot with slider in tkinter properly
The key part is the following codes
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
matplotlib.use('TkAgg')
root = Tk.Tk()
root.title("Embedding in TK")
fig = plt.Figure()
canvas = FigureCanvasTkAgg(fig, root)
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
My question focuses on 'contourf'.
X = np.arange(1,5,1)
Y = np.arange(1,5,1)
x , y = np.meshgrid(X,Y)
z = [
[0, 0, 0, 0],
[0, 1, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 0],
]
conto = plt.contourf(x,y,z)
canvas = FigureCanvasTkAgg(conto,root)
canvas.get_tk_widget().grid(column=0, row=1, pady=15, sticky=tk.W)
The above is what I tried to do; however, an error popped out
AttributeError: 'QuadContourSet' object has no attribute 'set_canvas'
Is there any way for 'contourf', like canvas, such that we can embed contourf into tkinter?