1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
import numpy as np
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import tkinter as tk
root = tk.Tk()
root.wm_title("Carto partie reelle")
fig = Figure(figsize=(5, 4), dpi=100)
a=fig.add_subplot(111)
x=np.linspace(-5,5,100)
a.plot(x,np.sin(x)) # on utilise la fonction sinus de Numpy
Graph = tk.Frame(root,width=500,height=450,bg='light blue')
Graph.pack()
can = FigureCanvasTkAgg(fig, master=Graph)
can.show()
can.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
can._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
toolbar = NavigationToolbar2TkAgg(can, root)
toolbar.update()
can._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
root.mainloop() |
Partager