Hello I have a code and I would like to display my two graphs on the same figure. Here is my code :
import Tkinter as tk
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import numpy as np
app = tk.Tk()
app.wm_title("Graphs")
fig = Figure(figsize=(6, 4), dpi=96)
a = np.array([1,2,3])
ax = fig.add_subplot(111)
bx = fig.add_subplot(111)
bx.plot(a,np.array([0,0.5,2]))
graph = FigureCanvasTkAgg(fig, master=app)
canvas = graph.get_tk_widget()
canvas.grid(row=0, column=0, rowspan = 11, padx =10, pady =5)
def updateScale(value):
ax.clear()
print "scale is now %s" % (value)
#a = np.array([1, 2, 3])
b = float(value)*a
ax.plot(a,b)
graph.show()
value = tk.DoubleVar()
scale = tk.Scale(app, variable=value, orient="horizontal",length = 100, from_=0.55, to=2.75, resolution = 0.01,command=updateScale)
scale.grid(row=0, column=1)
app.mainloop()
Everything is okay except that I don't watch bx... Any suggestions ? Thank you !