-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgraph_scroll_basic.py
More file actions
62 lines (39 loc) · 1.04 KB
/
graph_scroll_basic.py
File metadata and controls
62 lines (39 loc) · 1.04 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import matplotlib.pyplot as plt
import numpy as np
from ADnum_rev_timed_vis import ADnum
import ADmath_rev as ADmath
import ADgraph_GUI as ADgraph
#x = ADnum(1, ins=1, ind=0)
#f = x**3-3*x**2
#ADgraph.draw_graph_rev_dynamic(f, x.revder(f)[1])
#fig = ADgraph.draw_graph(f)
#plt.show()
#fig, figset = ADgraph.draw_graph_rev_dynamic(f, x.revder(f)[1])
#plt.show()
# define your x and y arrays to be plotted
t = np.linspace(start=0, stop=2*np.pi, num=100)
y1 = np.cos(t)
y2 = np.sin(t)
y3 = np.tan(t)
plots = [(t,y1), (t,y2), (t,y3)]
# now the real code :)
curr_pos = 0
def key_event(e):
global curr_pos
if e.key == "right":
curr_pos = curr_pos + 1
elif e.key == "left":
curr_pos = curr_pos - 1
else:
return
#curr_pos = curr_pos % len(figset)
#figset[curr_pos].show()
ax.cla()
ax.plot(plots[curr_pos][0], plots[curr_pos][1])
fig.canvas.draw()
fig = plt.figure()
fig.canvas.mpl_connect('key_press_event', key_event)
#figset[0].show()
ax = fig.add_subplot(111)
ax.plot(t,y1)
plt.show()