def _plot_line(
        self,
        start,
        end,
        data
        ):
        """
        plot line from start = (x0, y0) to end = (x1, y1)
        """

        clipped_line = self.canvas._clip_line(start, end)

        if clipped_line is None:
            return False

        start, end = clipped_line

        x0 = self.get_coordinates(
            start[0],
            self.canvas.min_x,
            self.canvas.step_x
        )
        y0 = self.get_coordinates(
            start[1],
            self.canvas.min_y,
            self.canvas.step_y
        )
        x1 = self.get_coordinates(
            end[0],
            self.canvas.min_x,
            self.canvas.step_x
        )
        y1 = self.get_coordinates(
            end[1],
            self.canvas.min_y,
            self.canvas.step_y
        )

        if (x0, y0) == (x1, y1):
            return True

        #x_zero_coordinates = self.get_coordinates(
        #    0,
        #    self.canvas.min_x,
        #    self.canvas.step_x
        #)
        y_zero_coordinates = self.get_coordinates(
            0,
            self.canvas.min_y,
            self.canvas.step_y,
            limits = [1, self.canvas.y_size]
        )

        if start[0] - end[0] == 0:
            draw_symbol = u"|"
        elif start[1] - end[1] == 0:
            draw_symbol = "-"
        else:
            slope =\
                (1.0 / self.canvas.ratio) * (end[1] - start[1])\
                / (end[0] - start[0])
            draw_symbol = self._get_symbol_by_slope(slope, data.marker)

        dx = x1 - x0
        dy = y1 - y0
        if abs(dx) > abs(dy):
            s = sign(dx)
            slope = float(dy) / dx
            for i in range(0, abs(int(dx))):
                current_draw_symbol = draw_symbol
                x = i * s
                current_y = int(y0 + slope * x)
                if\
                    (self.draw_axes) and\
                    (current_y == y_zero_coordinates) and\
                    (draw_symbol == self.x_axis_symbol):
                    current_draw_symbol = "-"
                self.out_buffer[x0 + x][current_y] = current_draw_symbol
        else:
            s = sign(dy)
            slope = float(dx) / dy
            for i in range(0, abs(int(dy))):
                y = i * s
                current_draw_symbol = draw_symbol
                current_y = y0 + y
                if\
                    (self.draw_axes) and\
                    (current_y == y_zero_coordinates) and\
                    (draw_symbol == self.x_axis_symbol):
                    current_draw_symbol = "-"
                self.out_buffer[
                    int(x0 + slope * y)
                ][
                    current_y
                ] = current_draw_symbol

        return False
def _plot_line ( self , start , end , data ) : clipped_line = self . canvas . _clip_line ( start , end ) if clipped_line is None : return False start , end = clipped_line x0 = self . get_coordinates ( start [ 0 ] , self . canvas . min_x , self . canvas . step_x ) y0 = self . get_coordinates ( start [ 1 ] , self . canvas . min_y , self . canvas . step_y ) x1 = self . get_coordinates ( end [ 0 ] , self . canvas . min_x , self . canvas . step_x ) y1 = self . get_coordinates ( end [ 1 ] , self . canvas . min_y , self . canvas . step_y ) if ( x0 , y0 ) == ( x1 , y1 ) : return True y_zero_coordinates = self . get_coordinates ( 0 , self . canvas . min_y , self . canvas . step_y , limits = [ 1 , self . canvas . y_size ] ) if start [ 0 ] - end [ 0 ] == 0 : draw_symbol = u"|" elif start [ 1 ] - end [ 1 ] == 0 : draw_symbol = "-" else : slope = ( 1.0 / self . canvas . ratio ) * ( end [ 1 ] - start [ 1 ] ) / ( end [ 0 ] - start [ 0 ] ) draw_symbol = self . _get_symbol_by_slope ( slope , data . marker ) dx = x1 - x0 dy = y1 - y0 if abs ( dx ) > abs ( dy ) : s = sign ( dx ) slope = float ( dy ) / dx for i in range ( 0 , abs ( int ( dx ) ) ) : current_draw_symbol = draw_symbol x = i * s current_y = int ( y0 + slope * x ) if ( self . draw_axes ) and ( current_y == y_zero_coordinates ) and ( draw_symbol == self . x_axis_symbol ) : current_draw_symbol = "-" self . out_buffer [ x0 + x ] [ current_y ] = current_draw_symbol else : s = sign ( dy ) slope = float ( dx ) / dy for i in range ( 0 , abs ( int ( dy ) ) ) : y = i * s current_draw_symbol = draw_symbol current_y = y0 + y if ( self . draw_axes ) and ( current_y == y_zero_coordinates ) and ( draw_symbol == self . x_axis_symbol ) : current_draw_symbol = "-" self . out_buffer [ int ( x0 + slope * y ) ] [ current_y ] = current_draw_symbol return False
plot line from start = (x0, y0) to end = (x1, y1)