@@ -101,24 +101,24 @@ def add_value(self, value):
101101 # pylint: disable=no-else-return
102102 @staticmethod
103103 def _xintercept (
104- x1 , y1 , x2 , y2 , horizontal_y
104+ x_1 , y_1 , x_2 , y_2 , horizontal_y
105105 ): # finds intercept of the line and a horizontal line at horizontalY
106- slope = (y2 - y1 ) / (x2 - x1 )
107- b = y1 - slope * x1
106+ slope = (y_2 - y_1 ) / (x_2 - x_1 )
107+ b = y_1 - slope * x_1
108108
109- if slope == 0 and y1 != horizontal_y : # does not intercept horizontalY
109+ if slope == 0 and y_1 != horizontal_y : # does not intercept horizontalY
110110 return None
111111 else :
112112 xint = (
113113 horizontal_y - b
114114 ) / slope # calculate the x-intercept at position y=horizontalY
115115 return int (xint )
116116
117- def _plotLine (self , x1 , last_value , x2 , value , y_bottom , y_top ):
117+ def _plotline (self , x_1 , last_value , x_2 , value , y_bottom , y_top ):
118118
119- y2 = int (self .height * (y_top - value ) / (y_top - y_bottom ))
120- y1 = int (self .height * (y_top - last_value ) / (y_top - y_bottom ))
121- self .append (Line (x1 , y1 , x2 , y2 , self .color )) # plot the line
119+ y_2 = int (self .height * (y_top - value ) / (y_top - y_bottom ))
120+ y_1 = int (self .height * (y_top - last_value ) / (y_top - y_bottom ))
121+ self .append (Line (x_1 , y_1 , x_2 , y_2 , self .color )) # plot the line
122122
123123 # pylint: disable=invalid-name, too-many-branches, too-many-nested-blocks
124124
@@ -150,16 +150,14 @@ def update(self):
150150 if count == 0 :
151151 pass # don't draw anything for a first point
152152 else :
153- x2 = int (xpitch * count )
154- x1 = int (xpitch * (count - 1 ))
155-
156- # print("x1: {}, x2: {}".format(x1,x2))
153+ x_2 = int (xpitch * count )
154+ x_1 = int (xpitch * (count - 1 ))
157155
158156 if (self .y_bottom <= last_value <= self .y_top ) and (
159157 self .y_bottom <= value <= self .y_top
160158 ): # both points are in range, plot the line
161- self ._plotLine (
162- x1 , last_value , x2 , value , self .y_bottom , self .y_top
159+ self ._plotline (
160+ x_1 , last_value , x_2 , value , self .y_bottom , self .y_top
163161 )
164162
165163 else : # at least one point is out of range, clip one or both ends the line
@@ -170,10 +168,10 @@ def update(self):
170168 pass
171169 else :
172170 xint_bottom = self ._xintercept (
173- x1 , last_value , x2 , value , self .y_bottom
171+ x_1 , last_value , x_2 , value , self .y_bottom
174172 ) # get possible new x intercept points
175173 xint_top = self ._xintercept (
176- x1 , last_value , x2 , value , self .y_top
174+ x_1 , last_value , x_2 , value , self .y_top
177175 ) # on the top and bottom of range
178176
179177 if (xint_bottom is None ) or (
@@ -182,30 +180,30 @@ def update(self):
182180 pass
183181 else :
184182 # Initialize the adjusted values as the baseline
185- adj_x1 = x1
183+ adj_x_1 = x_1
186184 adj_last_value = last_value
187- adj_x2 = x2
185+ adj_x_2 = x_2
188186 adj_value = value
189187
190188 if value > last_value : # slope is positive
191- if xint_bottom >= x1 : # bottom is clipped
192- adj_x1 = xint_bottom
193- adj_last_value = self .y_bottom # y1
194- if xint_top <= x2 : # top is clipped
195- adj_x2 = xint_top
196- adj_value = self .y_top # y2
189+ if xint_bottom >= x_1 : # bottom is clipped
190+ adj_x_1 = xint_bottom
191+ adj_last_value = self .y_bottom # y_1
192+ if xint_top <= x_2 : # top is clipped
193+ adj_x_2 = xint_top
194+ adj_value = self .y_top # y_2
197195 else : # slope is negative
198- if xint_top >= x1 : # top is clipped
199- adj_x1 = xint_top
200- adj_last_value = self .y_top # y1
201- if xint_bottom <= x2 : # bottom is clipped
202- adj_x2 = xint_bottom
203- adj_value = self .y_bottom # y2
204-
205- self ._plotLine (
206- adj_x1 ,
196+ if xint_top >= x_1 : # top is clipped
197+ adj_x_1 = xint_top
198+ adj_last_value = self .y_top # y_1
199+ if xint_bottom <= x_2 : # bottom is clipped
200+ adj_x_2 = xint_bottom
201+ adj_value = self .y_bottom # y_2
202+
203+ self ._plotline (
204+ adj_x_1 ,
207205 adj_last_value ,
208- adj_x2 ,
206+ adj_x_2 ,
209207 adj_value ,
210208 self .y_bottom ,
211209 self .y_top ,
0 commit comments