Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from matplotlib.widgets import Slider
  4. import tkinter as tk
  5.  
  6. def b1():
  7.   plt.clf()
  8.   ax = fig.add_subplot(111)
  9.   x = np.arange(0, 10, 0.1)
  10.   y = np.sin(x)
  11.   ax.plot(x, y)
  12.   fig.canvas.draw_idle()
  13.  
  14. def b2():
  15.   plt.clf()
  16.   ax1 = fig.add_subplot(211)
  17.   ax2 = fig.add_subplot(212)
  18.   x = np.arange(0, 20, 0.1)
  19.   y = np.sin(x**2)
  20.   y2 = np.sin(np.sqrt(x))*2
  21.   ax1.plot(x, y)
  22.   ax2.plot(x, y2)
  23.   fig.canvas.draw_idle()
  24.  
  25. rt = tk.Tk()
  26. btn1 = tk.Button(rt, text='1', command=b1)
  27. btn2 = tk.Button(rt, text='2', command=b2)
  28. btn1.grid(column=0, row=0)
  29. btn2.grid(column=1, row=0)
  30. fig = plt.figure(figsize=(8, 4))
  31. plt.pause(0.01)
  32. rt.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement