@@ -61,55 +61,55 @@ def make_circle(center, radius: float, p, q, n_points: int) -> np.ndarray:
6161
6262# create sine and cosine data
6363xs = np .linspace (0 , 2 * np .pi , 360 )
64- sine = np .sin (xs * P )
65- cosine = np .cos (xs * Q )
64+ sine_data = np .sin (xs * P )
65+ cosine_data = np .cos (xs * Q )
6666
6767# circle data
6868circle_data = make_circle (center = (0 , 0 ), p = P , q = Q , radius = 1 , n_points = 360 )
6969
7070# make the circle line graphic, set the cmap transform using the sine function
71- circle_graphic = figure ["circle" ].add_line (
72- circle_data , thickness = 4 , cmap = "bwr" , cmap_transform = sine
71+ circle = figure ["circle" ].add_line (
72+ circle_data , thickness = 4 , cmap = "bwr" , cmap_transform = sine_data
7373)
7474
7575# line to show the circle radius
7676# use it to indicate the current position of the sine and cosine selctors (below)
7777radius_data = np .array ([[0 , 0 , 0 ], [* circle_data [0 ], 0 ]])
78- circle_radius_graphic = figure ["circle" ].add_line (
78+ circle_radius = figure ["circle" ].add_line (
7979 radius_data , thickness = 6 , colors = "magenta"
8080)
8181
8282# sine line graphic, cmap transform set from the sine function
83- sine_graphic = figure ["sin" ].add_line (
84- sine , thickness = 10 , cmap = "bwr" , cmap_transform = sine
83+ sine = figure ["sin" ].add_line (
84+ sine_data , thickness = 10 , cmap = "bwr" , cmap_transform = sine_data
8585)
8686
8787# cosine line graphic, cmap transform set from the sine function
8888# illustrates the sine function values on the cosine graphic
89- cosine_graphic = figure ["cos" ].add_line (
90- cosine , thickness = 10 , cmap = "bwr" , cmap_transform = sine
89+ cosine = figure ["cos" ].add_line (
90+ cosine_data , thickness = 10 , cmap = "bwr" , cmap_transform = sine_data
9191)
9292
9393# add linear selectors to the sine and cosine line graphics
94- sine_selector = sine_graphic .add_linear_selector ()
95- cosine_selector = cosine_graphic .add_linear_selector ()
94+ sine_selector = sine .add_linear_selector ()
95+ cosine_selector = cosine .add_linear_selector ()
9696
9797
9898def set_circle_cmap (ev ):
9999 # sets the cmap transforms
100100
101101 cmap_transform = ev .graphic .data [:, 1 ] # y-val data of the sine or cosine graphic
102- for g in [sine_graphic , cosine_graphic ]:
102+ for g in [sine , cosine ]:
103103 g .cmap .transform = cmap_transform
104104
105105 # set circle cmap transform
106- circle_graphic .cmap .transform = cmap_transform
106+ circle .cmap .transform = cmap_transform
107107
108108# when the sine or cosine graphic is clicked, the cmap_transform
109109# of the sine, cosine and circle line graphics are all set from
110110# the y-values of the clicked line
111- sine_graphic .add_event_handler (set_circle_cmap , "click" )
112- cosine_graphic .add_event_handler (set_circle_cmap , "click" )
111+ sine .add_event_handler (set_circle_cmap , "click" )
112+ cosine .add_event_handler (set_circle_cmap , "click" )
113113
114114
115115def set_x_val (ev ):
@@ -120,7 +120,7 @@ def set_x_val(ev):
120120 sine_selector .selection = value
121121 cosine_selector .selection = value
122122
123- circle_radius_graphic .data [1 , :- 1 ] = circle_data [index ]
123+ circle_radius .data [1 , :- 1 ] = circle_data [index ]
124124
125125# add same event handler to both graphics
126126sine_selector .add_event_handler (set_x_val , "selection" )
@@ -138,19 +138,19 @@ def __init__(self, figure, size, location, title):
138138 self ._q = 1
139139
140140 def _set_data (self ):
141- global sine_graphic , cosine_graphic , circle_graphic , circle_radius_graphic , circle_data
141+ global sine , cosine , circle , circle_radius , circle_data
142142
143143 # make new data
144- sine = np .sin (xs * self ._p )
145- cosine = np .cos (xs * self ._q )
144+ sine_data = np .sin (xs * self ._p )
145+ cosine_data = np .cos (xs * self ._q )
146146 circle_data = make_circle (center = (0 , 0 ), p = self ._p , q = self ._q , radius = 1 , n_points = 360 )
147147
148148
149149 # set the graphics
150- sine_graphic .data [:, 1 ] = sine
151- cosine_graphic .data [:, 1 ] = cosine
152- circle_graphic .data [:, :2 ] = circle_data
153- circle_radius_graphic .data [1 , :- 1 ] = circle_data [sine_selector .get_selected_index ()]
150+ sine .data [:, 1 ] = sine_data
151+ cosine .data [:, 1 ] = cosine_data
152+ circle .data [:, :2 ] = circle_data
153+ circle_radius .data [1 , :- 1 ] = circle_data [sine_selector .get_selected_index ()]
154154
155155 def update (self ):
156156 flag_set_data = False
0 commit comments