Exemplo n.º 1
0
	def draw(self, renderer):
		x, y = self.get_data()

		if len(x) == 2 or len(y) == 2:
			xlim = self.axes.get_xlim()
			ylim = self.axes.get_ylim()

			x0, y0 = x[0], y[0]
			x1, y1 = x[1], y[1]

			if x0 == x1:	# vertical
				x, y = (x0, x0), ylim
			elif y0 == y1:	# horizontal
				x, y = xlim, (y0, y0)
			else:
				# coeff != 0
				coeff = float(y1 - y0) / (x1 - x0)

				minx = (ylim[0] - y0) / coeff + x0
				maxx = (ylim[1] - y0) / coeff + x0
				miny = coeff * (xlim[0] - x0) + y0
				maxy = coeff * (xlim[1] - x0) + y0

				if coeff > 0:
					x = max(minx, xlim[0]), min(maxx, xlim[1])
					y = max(miny, ylim[0]), min(maxy, ylim[1])
				else:
					x = max(maxx, xlim[0]), min(minx, xlim[1])
					y = min(miny, ylim[1]), max(maxy, ylim[0])


			self.set_data(x, y)

		Line2D.draw(self, renderer)
Exemplo n.º 2
0
    def draw(self, renderer):
        x, y = self.get_data()

        if len(x) == 2 or len(y) == 2:
            xlim = self.axes.get_xlim()
            ylim = self.axes.get_ylim()

            x0, y0 = x[0], y[0]
            x1, y1 = x[1], y[1]

            if x0 == x1:  # vertical
                x, y = (x0, x0), ylim
            elif y0 == y1:  # horizontal
                x, y = xlim, (y0, y0)
            else:
                # coeff != 0
                coeff = float(y1 - y0) / (x1 - x0)

                minx = (ylim[0] - y0) / coeff + x0
                maxx = (ylim[1] - y0) / coeff + x0
                miny = coeff * (xlim[0] - x0) + y0
                maxy = coeff * (xlim[1] - x0) + y0

                if coeff > 0:
                    x = max(minx, xlim[0]), min(maxx, xlim[1])
                    y = max(miny, ylim[0]), min(maxy, ylim[1])
                else:
                    x = max(maxx, xlim[0]), min(minx, xlim[1])
                    y = min(miny, ylim[1]), max(maxy, ylim[0])

            self.set_data(x, y)

        Line2D.draw(self, renderer)
Exemplo n.º 3
0
    def draw(self, renderer):
        """Draw the line and arrowhead using the passed renderer.
        """
        # if self._invalid:
        #     self.recache()
        renderer.open_group('arrowline2d')
        if not self._visible:
            return

        Line2D.draw(self, renderer)

        if self._arrow is not None:
            gc = renderer.new_gc()
            self._set_gc_clip(gc)
            gc.set_foreground(self._arrowedgecolor)
            gc.set_linewidth(self._arrowedgewidth)
            gc.set_alpha(self._alpha)
            funcname = self.arrows.get(self._arrow, '_draw_nothing')
        if funcname != '_draw_nothing':
            tpath, affine = self._transformed_path\
                                .get_transformed_points_and_affine()
            arrow_func = getattr(self, funcname)
            arrow_func(renderer, gc, tpath, affine.frozen())

        renderer.close_group('arrowline2d')
Exemplo n.º 4
0
 def draw(self, renderer):
     xlim = self.ax.get_xlim()
     ind0, ind1 = np.searchsorted(self.xorig, xlim)
     self._x = self.xorig[ind0:ind1]
     self._y = self.yorig[ind0:ind1]
     N = len(self._x)
     if N<1000:
         self._marker = 's'
         self._linestyle = '-'
     else:
         self._marker = None
         self._linestyle = '-'
     Line2D.draw(self, renderer)
Exemplo n.º 5
0
    def draw(self, renderer):
        xlim = self.ax.get_xlim()

        ind0, ind1 = np.searchsorted(self.xorig, xlim)
        self._x = self.xorig[ind0:ind1]
        self._y = self.yorig[ind0:ind1]
        N = len(self._x)
        if N < 1000:
            self._marker = 's'
            self._linestyle = '-'
        else:
            self._marker = None
            self._linestyle = '-'

        Line2D.draw(self, renderer)