コード例 #1
0
ファイル: lines.py プロジェクト: mgiuca-google/matplotlib
 def _get_rgba_face(self, alt=False):
     facecolor = self._get_markerfacecolor(alt=alt)
     if is_string_like(facecolor) and facecolor.lower() == 'none':
         rgbaFace = None
     else:
         rgbaFace = colorConverter.to_rgba(facecolor, self._alpha)
     return rgbaFace
コード例 #2
0
ファイル: lines.py プロジェクト: mgiuca-google/matplotlib
 def _get_rgba_ln_color(self, alt=False):
     ln_color = self._color
     if is_string_like(ln_color) and ln_color.lower() == 'none':
         rgba_ln = None
     else:
         rgba_ln = colorConverter.to_rgba(ln_color, self._alpha)
     return rgba_ln
コード例 #3
0
ファイル: lines.py プロジェクト: PierreBdR/matplotlib
 def _get_rgba_ln_color(self, alt=False):
     ln_color = self._color
     if is_string_like(ln_color) and ln_color.lower() == 'none':
         rgba_ln = None
     else:
         rgba_ln = colorConverter.to_rgba(ln_color, self._alpha)
     return rgba_ln
コード例 #4
0
ファイル: lines.py プロジェクト: PierreBdR/matplotlib
 def _get_rgba_face(self, alt=False):
     facecolor = self._get_markerfacecolor(alt=alt)
     if is_string_like(facecolor) and facecolor.lower() == 'none':
         rgbaFace = None
     else:
         rgbaFace = colorConverter.to_rgba(facecolor, self._alpha)
     return rgbaFace
コード例 #5
0
ファイル: contour.py プロジェクト: jtomase/matplotlib
    def _process_colors(self, colors, alpha, lev, cmap):
        """
        Color argument processing for contouring.

        Note that we base the color mapping on the contour levels,
        not on the actual range of the Z values.  This means we
        don't have to worry about bad values in Z, and we always have
        the full dynamic range available for the selected levels.
        """
        Nlev = len(lev)
        collections = []
        if colors is not None:

            if is_string_like(colors):
                colors = [colors] * Nlev
            elif iterable(colors) and len(colors) < Nlev:
                colors = list(colors) * Nlev
            else:
                try: gray = float(colors)
                except TypeError: pass
                else:  colors = [gray] * Nlev

            tcolors = [(colorConverter.to_rgba(c, alpha),) for c in colors]
            mappable = None
        else:
            mappable = ContourMappable(lev, collections, cmap=cmap)
            mappable.set_array(lev)
            mappable.autoscale()
            tcolors = [ (tuple(rgba),) for rgba in mappable.to_rgba(lev)]
        return tcolors, mappable, collections
コード例 #6
0
ファイル: image.py プロジェクト: jtomase/matplotlib
    def make_image(self, flipy):        

        if self._A is not None:
            x = self.to_rgba(self._A, self._alpha)
            im = _image.fromarray(x, 0)
        else:
            raise RuntimeError('You must first set the image array or the image attribute')

        bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0)
        im.set_bg( *bg)
        im.is_grayscale = (self.cmap.name == "gray" and
                           len(self._A.shape) == 2)
        
        im.set_aspect(self._aspectd[self._aspect])        
        im.set_interpolation(self._interpd[self._interpolation])



        # image input dimensions
        numrows, numcols = im.get_size()
        im.reset_matrix()

        xmin, xmax, ymin, ymax = self.get_extent() 
        dxintv = xmax-xmin
        dyintv = ymax-ymin

        # the viewport scale factor
        sx = dxintv/self.axes.viewLim.width()
        sy = dyintv/self.axes.viewLim.height()

        if im.get_interpolation()!=_image.NEAREST:
            im.apply_translation(-1, -1)

        # the viewport translation
        tx = (xmin-self.axes.viewLim.xmin())/dxintv * numcols
        if flipy: 
            ty = -(ymax-self.axes.viewLim.ymax())/dyintv * numrows
        else:
            ty = (ymin-self.axes.viewLim.ymin())/dyintv * numrows

        l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds()

        im.apply_translation(tx, ty)
        im.apply_scaling(sx, sy)

        # resize viewport to display
        rx = widthDisplay / numcols
        ry = heightDisplay  / numrows

        if im.get_aspect()==_image.ASPECT_PRESERVE:
            if ry < rx: rx = ry
            # todo: center the image in viewport
            im.apply_scaling(rx, rx)
        else:
            im.apply_scaling(rx, ry)

        #print tx, ty, sx, sy, rx, ry, widthDisplay, heightDisplay
        im.resize(int(widthDisplay+0.5), int(heightDisplay+0.5))
        return im
コード例 #7
0
 def _get_color(self, c, N=1):
     if looks_like_color(c):
         return  [colorConverter.to_rgba(c)]*N
     elif iterable(c) and len(c) and iterable(c[0]) and len(c[0])==4:
         # looks like a tuple of rgba
         return c
     else:
         raise TypeError('c must be a matplotlib color arg or nonzero length sequence of rgba tuples')
コード例 #8
0
ファイル: collections.py プロジェクト: jtomase/matplotlib
 def _get_color(self, c, N=1):
     if looks_like_color(c):
         return  [colorConverter.to_rgba(c)]*N
     elif iterable(c) and len(c) and iterable(c[0]) and len(c[0])==4:
         # looks like a tuple of rgba
         return c
     else:
         raise TypeError('c must be a matplotlib color arg or nonzero length sequence of rgba tuples')
コード例 #9
0
 def _draw_circle_collection(self, renderer):        
     colors = ( colorConverter.to_rgba(self._color, self.get_alpha()), )
     collection = RegularPolyCollection(
         self.figure.dpi,
         numsides=20, rotation=0, sizes=(self._markersize,),
         facecolors = colors,
         offsets = zip(self._x, self._y),
         transOffset = self._transform,             
         )
     collection.draw(renderer)
コード例 #10
0
    def make_image(self):
        if self._A is None:
            raise RuntimeError("You must first set the image array")

        x0, y0, v_width, v_height = self.axes.viewLim.get_bounds()
        l, b, width, height = self.axes.bbox.get_bounds()
        im = _image.pcolor(self._Ax, self._Ay, self._A, height, width, (x0, x0 + v_width, y0, y0 + v_height))

        bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0)
        im.set_bg(*bg)
        return im
コード例 #11
0
    def make_image(self):
        if self._A is None:
            raise RuntimeError('You must first set the image array')

        x = self.to_rgba(self._A, self._alpha)

        im = _image.fromarray(x, 1)
        im.set_bg(*colorConverter.to_rgba(self.figure.get_facecolor(), 0))
        im.is_grayscale = (self.cmap.name == "gray"
                           and len(self._A.shape) == 2)
        return im
コード例 #12
0
ファイル: image.py プロジェクト: pv/matplotlib-cvs
    def make_image(self):
        if self._A is None:
            raise RuntimeError('You must first set the image array')

        x = self.to_rgba(self._A, self._alpha)

        im = _image.fromarray(x, 1)
        im.set_bg( *colorConverter.to_rgba(self.figure.get_facecolor(), 0) )
        im.is_grayscale = (self.cmap.name == "gray" and
                           len(self._A.shape) == 2)
        return im
コード例 #13
0
ファイル: lines.py プロジェクト: jtomase/matplotlib
 def _draw_circle_collection(self, renderer):
     colors = (colorConverter.to_rgba(self._color, self.get_alpha()), )
     collection = RegularPolyCollection(
         self.figure.dpi,
         numsides=20,
         rotation=0,
         sizes=(self._markersize, ),
         facecolors=colors,
         offsets=zip(self._x, self._y),
         transOffset=self._transform,
     )
     collection.draw(renderer)
コード例 #14
0
    def _update(self):
        self.update_from(self.patch)
        if self.props is not None:
            self.update(self.props)
        else:
            r,g,b,a = colorConverter.to_rgba(self.patch.get_facecolor())
            rho = 0.3
            r = rho*r
            g = rho*g
            b = rho*b

            self.set_facecolor((r,g,b))
            self.set_edgecolor((r,g,b))
コード例 #15
0
    def _update(self):
        self.update_from(self.patch)
        if self.props is not None:
            self.update(self.props)
        else:
            r, g, b, a = colorConverter.to_rgba(self.patch.get_facecolor())
            rho = 0.3
            r = rho * r
            g = rho * g
            b = rho * b

            self.set_facecolor((r, g, b))
            self.set_edgecolor((r, g, b))
コード例 #16
0
    def make_image(self):
        if self._A is None:
            raise RuntimeError('You must first set the image array')

        x0, y0, v_width, v_height = self.axes.viewLim.get_bounds()
        l, b, width, height = self.axes.bbox.get_bounds()
        im = _image.pcolor(
            self._Ax,
            self._Ay,
            self._A,
            height,
            width,
            (x0, x0 + v_width, y0, y0 + v_height),
        )

        bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0)
        im.set_bg(*bg)
        return im
コード例 #17
0
    def make_image(self):
        if self._A is not None:
            if self._imcache is None:
                if typecode(self._A) == UInt8:
                    im = _image.frombyte(self._A, 0)
                    im.is_grayscale = False
                else:
                    x = self.to_rgba(self._A, self._alpha)
                    im = _image.fromarray(x, 0)
                    if len(self._A.shape) == 2:
                        im.is_grayscale = self.cmap.is_gray()
                    else:
                        im.is_grayscale = False
                self._imcache = im
            else:
                im = self._imcache
        else:
            raise RuntimeError(
                'You must first set the image array or the image attribute')

        bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0)

        if self.origin == 'upper':
            im.flipud_in()

        im.set_bg(*bg)

        im.set_interpolation(self._interpd[self._interpolation])

        # image input dimensions
        numrows, numcols = im.get_size()
        im.reset_matrix()

        xmin, xmax, ymin, ymax = self.get_extent()
        dxintv = xmax - xmin
        dyintv = ymax - ymin

        # the viewport scale factor
        sx = dxintv / self.axes.viewLim.width()
        sy = dyintv / self.axes.viewLim.height()

        if im.get_interpolation() != _image.NEAREST:
            im.apply_translation(-1, -1)

        # the viewport translation
        tx = (xmin - self.axes.viewLim.xmin()) / dxintv * numcols

        #if flipy:
        #    ty = -(ymax-self.axes.viewLim.ymax())/dyintv * numrows
        #else:
        #    ty = (ymin-self.axes.viewLim.ymin())/dyintv * numrows
        ty = (ymin - self.axes.viewLim.ymin()) / dyintv * numrows

        l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds()

        im.apply_translation(tx, ty)
        im.apply_scaling(sx, sy)

        # resize viewport to display
        rx = widthDisplay / numcols
        ry = heightDisplay / numrows
        im.apply_scaling(rx, ry)

        #print tx, ty, sx, sy, rx, ry, widthDisplay, heightDisplay
        im.resize(int(widthDisplay + 0.5),
                  int(heightDisplay + 0.5),
                  norm=self._filternorm,
                  radius=self._filterrad)

        if self.origin == 'upper':
            im.flipud_in()

        return im
コード例 #18
0
    def make_image(self):
        if self._A is not None:
            if self._imcache is None:
                if typecode(self._A) == UInt8:
                    im = _image.frombyte(self._A, 0)
                    im.is_grayscale = False
                else:
                    x = self.to_rgba(self._A, self._alpha)
                    im = _image.fromarray(x, 0)
                    if len(self._A.shape) == 2:
                        im.is_grayscale = self.cmap.is_gray()
                    else:
                        im.is_grayscale = False
                self._imcache = im
            else:
                im = self._imcache
        else:
            raise RuntimeError("You must first set the image array or the image attribute")

        bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0)

        if self.origin == "upper":
            im.flipud_in()

        im.set_bg(*bg)

        im.set_interpolation(self._interpd[self._interpolation])

        # image input dimensions
        numrows, numcols = im.get_size()
        im.reset_matrix()

        xmin, xmax, ymin, ymax = self.get_extent()
        dxintv = xmax - xmin
        dyintv = ymax - ymin

        # the viewport scale factor
        sx = dxintv / self.axes.viewLim.width()
        sy = dyintv / self.axes.viewLim.height()

        if im.get_interpolation() != _image.NEAREST:
            im.apply_translation(-1, -1)

        # the viewport translation
        tx = (xmin - self.axes.viewLim.xmin()) / dxintv * numcols

        # if flipy:
        #    ty = -(ymax-self.axes.viewLim.ymax())/dyintv * numrows
        # else:
        #    ty = (ymin-self.axes.viewLim.ymin())/dyintv * numrows
        ty = (ymin - self.axes.viewLim.ymin()) / dyintv * numrows

        l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds()

        im.apply_translation(tx, ty)
        im.apply_scaling(sx, sy)

        # resize viewport to display
        rx = widthDisplay / numcols
        ry = heightDisplay / numrows
        im.apply_scaling(rx, ry)

        # print tx, ty, sx, sy, rx, ry, widthDisplay, heightDisplay
        im.resize(int(widthDisplay + 0.5), int(heightDisplay + 0.5), norm=self._filternorm, radius=self._filterrad)

        if self.origin == "upper":
            im.flipud_in()

        return im