Example #1
0
    def __init__(
        self,
        edgecolor=None,
        facecolor=None,
        linewidth=None,
        antialiased=None,
        hatch=None,
        fill=1,
        xunits=None,
        yunits=None,
        **kwargs
    ):
        Artist.__init__(self)

        if edgecolor is None:
            edgecolor = rcParams["patch.edgecolor"]
        if facecolor is None:
            facecolor = rcParams["patch.facecolor"]
        if linewidth is None:
            linewidth = rcParams["patch.linewidth"]
        if antialiased is None:
            antialiased = rcParams["patch.antialiased"]

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self._hatch = hatch
        self.fill = fill
        self._xunits = xunits
        self._yunits = yunits
        self._xunits_id, self._yunits_id = None, None

        if len(kwargs):
            setp(self, **kwargs)
Example #2
0
    def __init__(self, 
                 x=0, y=0, text='',
                 color=None,          # defaults to rc params
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 multialignment=None,
                 fontproperties=None, # defaults to FontProperties()
                 rotation=None,
                 ):

        Artist.__init__(self)
        self.cached = {}
        self._x, self._y = x, y

        if color is None: color = rcParams['text.color']
        if fontproperties is None: fontproperties=FontProperties()

        self._color = color
        self._text = text
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment

        
        
        self._rotation = rotation
        self._fontproperties = fontproperties
Example #3
0
    def __init__(self, x=0, y=0, text='',
                 color='k',
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 fontname='Sans',
                 fontsize=10,
                 fontweight='bold',
                 fontangle='normal',
                 rotation=None,
                 ):
        Artist.__init__(self)
        self._x, self._y = x, y

        self._color = color
        self._text = text
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._rotation = rotation
        self._fontname = fontname
        self._fontsize = fontsize
        self._fontweight = fontweight
        self._fontangle = fontangle


        self._reset=1
        self._drawn = 0
        self._eraseImg = None
        self._lastXY = 0,0
Example #4
0
    def __init__(self, axes, pickradius=15):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes
        self.major = Ticker()
        self.minor = Ticker()
        self.callbacks = CallbackRegistry(('units', 'units finalize'))

        #class dummy:
        #    locator = None
        #    formatter = None
        #self.major = dummy()
        #self.minor = dummy()

        self.label = self._get_label()
        self.offsetText = self._get_offset_text()
        self.majorTicks = []
        self.minorTicks = []
        self.pickradius = pickradius

        self.cla()
Example #5
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes

        self.set_major_locator(AutoLocator())
        self.set_minor_locator(NullLocator())

        self.set_major_formatter(ScalarFormatter())
        self.set_minor_formatter(NullFormatter())

        # whether the grids are on
        self._gridOnMajor = rcParams['axes.grid']
        self._gridOnMinor = False

        self.label = self._get_label()
        self._set_artist_props(self.label)

        # build a few default ticks; grow as necessary later; only
        # define 1 so properties set on ticks will be copied as they
        # grow
        self.majorTicks = [self._get_tick(major=True) for i in range(1)]
        self.minorTicks = [self._get_tick(major=False) for i in range(1)]
Example #6
0
    def __init__(self, ax, loc=None, bbox=None):

        Artist.__init__(self)

        if is_string_like(loc) and loc not in self.codes:
            warnings.warn('Unrecognized location %s. Falling back on '
                          'bottom; valid locations are\n%s\t' %
                          (loc, '\n\t'.join(self.codes.iterkeys())))
            loc = 'bottom'
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True

        self.set_clip_on(False)

        self._cachedRenderer = None
Example #7
0
    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 antialiased=None,
                 hatch=None,
                 fill=1,
                 xunits=None,
                 yunits=None,
                 **kwargs):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self._hatch = hatch
        self.fill = fill
        self._xunits = xunits
        self._yunits = yunits
        self._xunits_id, self._yunits_id = None, None

        if len(kwargs): setp(self, **kwargs)
Example #8
0
    def __init__(self,
                 edgecolor=None,   
                 facecolor=None,
                 linewidth=None,
                 antialiased = None, 
                 fill=1,
                 **kwargs
                 ):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased        
        self.fill = fill


        for k,v in kwargs.items():
            func = 'set_' + k            
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Example #9
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)
        
        self.axes = axes

        self.set_major_locator( AutoLocator() )
        self.set_minor_locator( NullLocator() )

        self.set_major_formatter( ScalarFormatter() )
        self.set_minor_formatter( NullFormatter() )
        
        # whether the grids are on
        self._gridOnMajor = rcParams['axes.grid']  
        self._gridOnMinor = False

        self.label = self._get_label()
        self._set_artist_props(self.label)

        # build a few default ticks; grow as necessary later; only
        # define 1 so properties set on ticks will be copied as they
        # grow
        self.majorTicks = [self._get_tick(major=True)  for i in range(1)]
        self.minorTicks = [self._get_tick(major=False) for i in range(1)]       
Example #10
0
    def __init__(self,
                 edgecolor=None,   
                 facecolor=None,
                 linewidth=None,
                 antialiased = None,
                 fill=1,
                 **kwargs
                 ):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased        
        self.fill = fill

        # set up some abbreviations for easier interactive use
        for func, abbrev in self._aliases:
            self.__dict__['set_%s'%abbrev] = getattr(self, 'set_%s'%func)
            self.__dict__['get_%s'%abbrev] = getattr(self, 'get_%s'%func)

        for k,v in kwargs.items():
            func = 'set_' + k            
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Example #11
0
    def __init__(self, 
                 x=0, y=0, text='',
                 color=None,          # defaults to rc params
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 multialignment=None,
                 fontproperties=None, # defaults to FontProperties()
                 rotation=None,
                 ):

        Artist.__init__(self)
        if not is_string_like(text):
            raise TypeError('text must be a string type')
        self.cached = {}
        self._x, self._y = x, y

        if color is None: color = rcParams['text.color']
        if fontproperties is None: fontproperties=FontProperties()

        self._color = color
        self.set_text(text)
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment        
        self._rotation = rotation
        self._fontproperties = fontproperties
        self._bbox = None
        self._renderer = None        
Example #12
0
    def __init__(self, ax, loc=None, bbox=None):

        Artist.__init__(self)

        if is_string_like(loc) and loc not in self.codes:
            warnings.warn(
                "Unrecognized location %s. Falling back on "
                "bottom; valid locations are\n%s\t" % (loc, "\n\t".join(self.codes.iterkeys()))
            )
            loc = "bottom"
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True

        self._cachedRenderer = None
Example #13
0
    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 antialiased=None,
                 fill=1,
                 **kwargs):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self.fill = fill

        # set up some abbreviations for easier interactive use
        for func, abbrev in self._aliases:
            self.__dict__['set_%s' % abbrev] = getattr(self, 'set_%s' % func)
            self.__dict__['get_%s' % abbrev] = getattr(self, 'get_%s' % func)

        for k, v in kwargs.items():
            func = 'set_' + k
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Example #14
0
    def __init__(
            self,
            figsize=None,  # defaults to rc figure.figsize
            dpi=None,  # defaults to rc figure.dpi
            facecolor=None,  # defaults to rc figure.facecolor
            edgecolor=None,  # defaults to rc figure.edgecolor
            linewidth=1.0,  # the default linewidth of the frame
            frameon=True,  # whether or not to draw the figure frame
            subplotpars=None,  # default to rc
    ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)
        #self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}  # axes args we've seen

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._unit_conversions = {}

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point(Value(0), Value(0))
        self.ur = Point(self.figwidth * self.dpi, self.figheight * self.dpi)
        self.bbox = Bbox(self.ll, self.ur)

        self.frameon = frameon

        self.transFigure = get_bbox_transform(unit_bbox(), self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self.clf()

        self._cachedRenderer = None
Example #15
0
    def __init__(self, ax,
                 cmap = None,
                 norm = None,
                 aspect=None,
                 interpolation=None,
                 origin=None,
                 extent=None,
                 ):

        """
        aspect, interpolation and cmap default to their rc setting

        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1

        extent is a data xmin, xmax, ymin, ymax for making image plots
        registered with data plots.  Default is the image dimensions
        in pixels
        
        """
        Artist.__init__(self)        
        cm.ScalarMappable.__init__(self, norm, cmap)

        if origin is None: origin = rcParams['image.origin']
        self.origin = origin
        self._extent = extent      

        # map interpolation strings to module constants
        self._interpd = {
            'bicubic'     : _image.BICUBIC,
            'bilinear'    : _image.BILINEAR,
            'blackman100' : _image.BLACKMAN100,
            'blackman256' : _image.BLACKMAN256,
            'blackman64'  : _image.BLACKMAN64,
            'nearest'     : _image.NEAREST,
            'sinc144'     : _image.SINC144,
            'sinc256'     : _image.SINC256,
            'sinc64'      : _image.SINC64,
            'spline16'    : _image.SPLINE16,
            'spline36'    : _image.SPLINE36,       
        }

        # map aspect ratio strings to module constants
        self._aspectd = {
            'free'     : _image.ASPECT_FREE,
            'preserve' : _image.ASPECT_PRESERVE,
        }

        # reverse interp dict
        self._interpdr = dict([ (v,k) for k,v in self._interpd.items()])

        # reverse aspect dict
        self._aspectdr = dict([ (v,k) for k,v in self._aspectd.items()])

        if aspect is None: aspect = rcParams['image.aspect']
        if interpolation is None: interpolation = rcParams['image.interpolation']        
        
        self.set_interpolation(interpolation)
        self.set_aspect( aspect)
        self.axes = ax
Example #16
0
    def __init__(self,
                 figsize   = None,  # defaults to rc figure.figsize
                 dpi       = None,  # defaults to rc figure.dpi
                 facecolor = None,  # defaults to rc figure.facecolor
                 edgecolor = None,  # defaults to rc figure.edgecolor
                 linewidth = 1.0,   # the default linewidth of the frame
                 frameon = True,    # whether or not to draw the figure frame
                 subplotpars = None, # default to rc
                 ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)
        #self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}          # axes args we've seen

        if figsize is None  : figsize   = rcParams['figure.figsize']
        if dpi is None      : dpi       = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._unit_conversions = {}

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point( Value(0), Value(0) )
        self.ur = Point( self.figwidth*self.dpi,
                         self.figheight*self.dpi )
        self.bbox = Bbox(self.ll, self.ur)

        self.frameon = frameon

        self.transFigure = get_bbox_transform( unit_bbox(), self.bbox)



        self.figurePatch = Rectangle(
            xy=(0,0), width=1, height=1,
            facecolor=facecolor, edgecolor=edgecolor,
            linewidth=linewidth,
            )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self.clf()

        self._cachedRenderer = None
Example #17
0
    def __init__(self, axes, loc, label,
                 size   = None,  # points
                 gridOn = None, # defaults to axes.grid
                 tick1On = True,
                 tick2On = True,
                 label1On = True,
                 label2On = False,
                 major = True,
                 ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None: gridOn = rcParams['axes.grid']

        self.set_figure(axes.figure)
        self.axes = axes

        name = self.__name__.lower()
        if size is None:
            if major:
                size = rcParams['%s.major.size'%name]
                pad = rcParams['%s.major.pad'%name]
            else:
                size = rcParams['%s.minor.size'%name]
                pad = rcParams['%s.minor.pad'%name]

        self._tickdir = rcParams['%s.direction'%name]
        if self._tickdir == 'in':
            self._xtickmarkers = (TICKUP, TICKDOWN)
            self._ytickmarkers = (TICKRIGHT, TICKLEFT)
            self._pad = Value(pad)
        else:
            self._xtickmarkers = (TICKDOWN, TICKUP)
            self._ytickmarkers = (TICKLEFT, TICKRIGHT)
            self._pad = Value(pad + size)

        self._loc = loc
        self._size = size

        self._padPixels = self.figure.dpi*self._pad*Value(1/72.0)


        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Example #18
0
    def __init__(self, axes, loc, label,
                 size   = None,  # points
                 gridOn = None, # defaults to axes.grid
                 tick1On = True,
                 tick2On = True,
                 label1On = True,
                 label2On = False,
                 major = True,
                 ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None: gridOn = rcParams['axes.grid']

        self.set_figure(axes.figure)
        self.axes = axes

        name = self.__name__.lower()
        if size is None:
            if major:
                size = rcParams['%s.major.size'%name]
                pad = rcParams['%s.major.pad'%name]
            else:
                size = rcParams['%s.minor.size'%name]
                pad = rcParams['%s.minor.pad'%name]

        self._tickdir = rcParams['%s.direction'%name]
        if self._tickdir == 'in':
            self._xtickmarkers = (TICKUP, TICKDOWN)
            self._ytickmarkers = (TICKRIGHT, TICKLEFT)
            self._pad = Value(pad)
        else:
            self._xtickmarkers = (TICKDOWN, TICKUP)
            self._ytickmarkers = (TICKLEFT, TICKRIGHT)
            self._pad = Value(pad + size)

        self._loc = loc
        self._size = size

        self._padPixels = self.figure.dpi*self._pad*Value(1/72.0)


        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Example #19
0
    def __init__(
        self, ax, cmap=None, norm=None, interpolation=None, origin=None, extent=None, filternorm=1, filterrad=4.0
    ):

        """
        interpolation and cmap default to their rc settings

        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1

        extent is a data xmin, xmax, ymin, ymax for making image plots
        registered with data plots.  Default is the image dimensions
        in pixels

        """
        Artist.__init__(self)
        cm.ScalarMappable.__init__(self, norm, cmap)

        if origin is None:
            origin = rcParams["image.origin"]
        self.origin = origin
        self._extent = extent
        self.set_filternorm(filternorm)
        self.set_filterrad(filterrad)

        # map interpolation strings to module constants
        self._interpd = {
            "nearest": _image.NEAREST,
            "bilinear": _image.BILINEAR,
            "bicubic": _image.BICUBIC,
            "spline16": _image.SPLINE16,
            "spline36": _image.SPLINE36,
            "hanning": _image.HANNING,
            "hamming": _image.HAMMING,
            "hermite": _image.HERMITE,
            "kaiser": _image.KAISER,
            "quadric": _image.QUADRIC,
            "catrom": _image.CATROM,
            "gaussian": _image.GAUSSIAN,
            "bessel": _image.BESSEL,
            "mitchell": _image.MITCHELL,
            "sinc": _image.SINC,
            "lanczos": _image.LANCZOS,
            "blackman": _image.BLACKMAN,
        }

        # reverse interp dict
        self._interpdr = dict([(v, k) for k, v in self._interpd.items()])

        if interpolation is None:
            interpolation = rcParams["image.interpolation"]

        self.set_interpolation(interpolation)
        self.axes = ax

        self._imcache = None
Example #20
0
 def __init__(
         self,
         figsize=None,  # defaults to rc figure.figsize
         dpi=None,  # defaults to rc figure.dpi
         facecolor=None,  # defaults to rc figure.facecolor
         edgecolor=None,  # defaults to rc figure.edgecolor
         linewidth=1.0,  # the default linewidth of the frame
         frameon=True,  # whether or not to draw the figure frame
         subplotpars=None,  # default to rc
 ):
     """
     *figsize*
         w,h tuple in inches
     *dpi*
         dots per inch
     *facecolor*
         the figure patch facecolor; defaults to rc ``figure.facecolor``
     *edgecolor*
         the figure patch edge color; defaults to rc ``figure.edgecolor``
     *linewidth*
         the figure patch edge linewidth; the default linewidth of the frame
     *frameon*
         if False, suppress drawing the figure frame
     *subplotpars*
         a :class:`SubplotParams` instance, defaults to rc
     """
     Artist.__init__(self)
     self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
     if figsize is None: figsize = rcParams['figure.figsize']
     if dpi is None: dpi = rcParams['figure.dpi']
     if facecolor is None: facecolor = rcParams['figure.facecolor']
     if edgecolor is None: edgecolor = rcParams['figure.edgecolor']
     self.dpi_scale_trans = Affine2D()
     self.dpi = dpi
     self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
     self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)
     self.frameon = frameon
     self.transFigure = BboxTransformTo(self.bbox)
     self.patch = self.figurePatch = Rectangle(
         xy=(0, 0),
         width=1,
         height=1,
         facecolor=facecolor,
         edgecolor=edgecolor,
         linewidth=linewidth,
     )
     self._set_artist_props(self.patch)
     self._hold = rcParams['axes.hold']
     self.canvas = None
     if subplotpars is None:
         subplotpars = SubplotParams()
     self.subplotpars = subplotpars
     self._axstack = Stack()  # maintain the current axes
     self.axes = []
     self.clf()
     self._cachedRenderer = None
Example #21
0
    def __init__(self, canvas, size=5, **kwprops):
        # A SyntaxError or TypeError will be received if the user tries to
        # supply the size as an arg AND a kwarg. So we don't have to worry
        # about a size property being set in Marker.__init__.

        Artist.__init__(self, canvas, **kwprops)

        self.setOrigin()
        self.setPosition()
        self.setSize(size)
Example #22
0
    def __init__(self, canvas, size=5, **kwprops):
        # A SyntaxError or TypeError will be received if the user tries to
        # supply the size as an arg AND a kwarg. So we don't have to worry
        # about a size property being set in Marker.__init__.

        Artist.__init__(self, canvas, **kwprops)

        self.setOrigin()
        self.setPosition()
        self.setSize(size)
Example #23
0
    def __init__(
            self,
            figsize=None,  # defaults to rc figure.figsize
            dpi=None,  # defaults to rc figure.dpi
            facecolor=None,  # defaults to rc figure.facecolor
            edgecolor=None,  # defaults to rc figure.edgecolor
            linewidth=1.0,  # the default linewidth of the frame
            frameon=True,  # whether or not to draw the figure frame
            subplotpars=None,  # default to rc
    ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._dpi_scale_trans = Affine2D()
        self.dpi = dpi
        self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
        self.bbox = TransformedBbox(self.bbox_inches, self._dpi_scale_trans)

        self.frameon = frameon

        self.transFigure = BboxTransformTo(self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = Stack()  # maintain the current axes
        self.axes = []
        self.clf()

        self._cachedRenderer = None
        self._autoLayout = rcParams['figure.autolayout']
Example #24
0
    def __init__(self, figure, canvas):
        """
        **Constructor**

        figure
            The figure to draw the plot on.
        canvas
            The canvas that the figure uses.
        """
        self._figure = figure
        Artist.__init__(self, canvas)
Example #25
0
    def __init__(self, x, y, lineWidth=1, color=ColorDispatcher().get('b')):
        Artist.__init__(self)
        #convert sequences to numeric arrays

        self._linewidth = lineWidth
        if is_string_like(color):
            color = ColorDispatcher().get(color)
        self._color = color
        self.verticalOffset = None

        self.set_data(x, y)
Example #26
0
    def __init__(self,
                 edgeColor=ColorDispatcher().get('k'),
                 faceColor=ColorDispatcher().get('b'),
                 fill=1,
                 ):

        Artist.__init__(self)
        self._edgecolor = edgeColor
        self._facecolor = faceColor
        self.fill = fill
        self._linewidth=1
Example #27
0
    def __init__(self, figure, canvas):
        """
        **Constructor**

        figure
            The figure to draw the plot on.
        canvas
            The canvas that the figure uses.
        """
        self._figure = figure
        Artist.__init__(self, canvas)
Example #28
0
    def __init__(
            self,
            edgeColor=ColorDispatcher().get('k'),
            faceColor=ColorDispatcher().get('b'),
            fill=1,
    ):

        Artist.__init__(self)
        self._edgecolor = edgeColor
        self._facecolor = faceColor
        self.fill = fill
        self._linewidth = 1
Example #29
0
    def __init__(
        self,
        axes,
        loc,
        label,
        size=None,  # points
        gridOn=None,  # defaults to axes.grid
        tick1On=True,
        tick2On=True,
        label1On=True,
        label2On=False,
        major=True,
    ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None:
            gridOn = rcParams["axes.grid"]

        self.set_figure(axes.figure)
        self.axes = axes

        if size is None:
            if major:
                size = rcParams["tick.major.size"]
                pad = rcParams["tick.major.pad"]
            else:
                size = rcParams["tick.minor.size"]
                pad = rcParams["tick.minor.pad"]

        self._loc = loc
        self._size = size
        self._pad = Value(pad)
        self._padPixels = self.figure.dpi * self._pad * Value(1 / 72.0)

        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Example #30
0
    def __init__(
        self,
        axes,
        loc,
        label,
        size=None,  # points
        gridOn=None,  # defaults to axes.grid
        tick1On=True,
        tick2On=True,
        label1On=True,
        label2On=False,
        major=True,
    ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None: gridOn = rcParams['axes.grid']

        self.set_figure(axes.figure)
        self.axes = axes

        if size is None:
            if major:
                size = rcParams['tick.major.size']
                pad = rcParams['tick.major.pad']
            else:
                size = rcParams['tick.minor.size']
                pad = rcParams['tick.minor.pad']

        self._loc = loc
        self._size = size
        self._pad = Value(pad)

        self._padPixels = self.figure.dpi * self._pad * Value(1 / 72.0)

        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Example #31
0
    def __init__(self,
                 figsize   = None,  # defaults to rc figure.figsize
                 dpi       = None,  # defaults to rc figure.dpi
                 facecolor = None,  # defaults to rc figure.facecolor
                 edgecolor = None,  # defaults to rc figure.edgecolor
                 linewidth = 1.0,   # the default linewidth of the frame
                 frameon = True,    # whether or not to draw the figure frame
                 subplotpars = None, # default to rc
                 ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)

        if figsize is None  : figsize   = rcParams['figure.figsize']
        if dpi is None      : dpi       = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

	self._dpi_scale_trans = Affine2D()
        self.dpi = dpi
	self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
	self.bbox = TransformedBbox(self.bbox_inches, self._dpi_scale_trans)

        self.frameon = frameon

        self.transFigure = BboxTransformTo(self.bbox)

        self.figurePatch = Rectangle(
            xy=(0,0), width=1, height=1,
            facecolor=facecolor, edgecolor=edgecolor,
            linewidth=linewidth,
            )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = Stack()  # maintain the current axes
        self.axes = []
        self.clf()

        self._cachedRenderer = None
        self._autoLayout = rcParams['figure.autolayout']
Example #32
0
    def __init__(self, canvas, **kwprops):

        initialProperties = {'width': 1,
                         'style': 'solid',
                         'cap': 'square',
                         'join': 'bevel',
                        }
        initialProperties.update(kwprops)

        Artist.__init__(self, canvas, **initialProperties)

        self.setOrigin()
        self.setPosition()
        self.setEnd()
Example #33
0
    def __init__(self, x, y,
                 lineWidth=1, 
                 color=ColorDispatcher().get('b')):
        Artist.__init__(self)
        #convert sequences to numeric arrays


        self._linewidth = lineWidth
        if is_string_like(color):
            color = ColorDispatcher().get(color)
        self._color = color
        self.verticalOffset = None
        
        self.set_data(x, y)
Example #34
0
    def __init__(self, canvas, **kwprops):

        initialProperties = {
            'width': 1,
            'style': 'solid',
            'cap': 'square',
            'join': 'bevel',
        }
        initialProperties.update(kwprops)

        Artist.__init__(self, canvas, **initialProperties)

        self.setOrigin()
        self.setPosition()
        self.setEnd()
Example #35
0
    def __init__(self, fig, cmap=None, norm=None, offsetx=0, offsety=0, origin=None):

        """
        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1

        """
        Artist.__init__(self)
        cm.ScalarMappable.__init__(self, norm, cmap)
        if origin is None:
            origin = rcParams["image.origin"]
        self.origin = origin
        self.figure = fig
        self.ox = offsetx
        self.oy = offsety
Example #36
0
    def __init__(self, canvas, text='', **kwprops):
        """
        If text is given as a kwprops in the initialization, it will not be used.
        """

        initialProperties = {'font': 'Times',
                             'text': text,
                             'horizontalalignment': 'center',
                             'verticalalignment': 'center',
                             'xoffset': 0,
                             'yoffset': 0,
                             'rotation': 'horizontal',
                            }
        initialProperties.update(kwprops)

        Artist.__init__(self, canvas, **initialProperties)
Example #37
0
    def __init__(
        self,
        figsize=None,  # defaults to rc figure.figsize
        dpi=None,  # defaults to rc figure.dpi
        facecolor=None,  # defaults to rc figure.facecolor
        edgecolor=None,  # defaults to rc figure.edgecolor
        linewidth=1.0,  # the default linewidth of the frame
        frameon=True,
    ):
        """
        paper size is a w,h tuple in inches
        DPI is dots per inch 
        """
        Artist.__init__(self)
        #self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}  # axes args we've seen

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point(Value(0), Value(0))
        self.ur = Point(self.figwidth * self.dpi, self.figheight * self.dpi)
        self.bbox = Bbox(self.ll, self.ur)
        self.frameon = frameon

        self.transFigure = get_bbox_transform(unit_bbox(), self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.clf()
Example #38
0
    def __init__(
        self,
        figsize=None,  # defaults to rc figure.figsize
        dpi=None,  # defaults to rc figure.dpi
        facecolor=None,  # defaults to rc figure.facecolor
        edgecolor=None,  # defaults to rc figure.edgecolor
        linewidth=1.0,  # the default linewidth of the frame
        frameon=True,
    ):
        """
        paper size is a w,h tuple in inches
        DPI is dots per inch 
        """
        Artist.__init__(self)
        # self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}  # axes args we've seen

        if figsize is None:
            figsize = rcParams["figure.figsize"]
        if dpi is None:
            dpi = rcParams["figure.dpi"]
        if facecolor is None:
            facecolor = rcParams["figure.facecolor"]
        if edgecolor is None:
            edgecolor = rcParams["figure.edgecolor"]

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point(Value(0), Value(0))
        self.ur = Point(self.figwidth * self.dpi, self.figheight * self.dpi)
        self.bbox = Bbox(self.ll, self.ur)
        self.frameon = frameon

        self.transFigure = get_bbox_transform(unit_bbox(), self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0), width=1, height=1, facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams["axes.hold"]
        self.canvas = None
        self.clf()
Example #39
0
    def __init__(
        self,
        x=0,
        y=0,
        text="",
        color=None,  # defaults to rc params
        verticalalignment="bottom",
        horizontalalignment="left",
        multialignment=None,
        fontproperties=None,  # defaults to FontProperties()
        rotation=None,
        linespacing=None,
        **kwargs
    ):
        """
        Create a :class:`~matplotlib.text.Text` instance at *x*, *y*
        with string *text*.

        Valid kwargs are
        %(Text)s
        """

        Artist.__init__(self)
        self.cached = maxdict(5)
        self._x, self._y = x, y

        if color is None:
            color = rcParams["text.color"]
        if fontproperties is None:
            fontproperties = FontProperties()
        elif is_string_like(fontproperties):
            fontproperties = FontProperties(fontproperties)

        self.set_text(text)
        self.set_color(color)
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment
        self._rotation = rotation
        self._fontproperties = fontproperties
        self._bbox = None
        self._renderer = None
        if linespacing is None:
            linespacing = 1.2  # Maybe use rcParam later.
        self._linespacing = linespacing
        self.update(kwargs)
Example #40
0
 def __init__(
     self,
     x=0,
     y=0,
     text='',
     color=None,  # defaults to rc params
     verticalalignment='center',
     horizontalalignment='center',
     multialignment=None,
     fontproperties=None,  # defaults to FontProperties()
     rotation=None,
     dashlength=0.0,
     dashdirection=0,
     dashrotation=None,
     dashpad=3,
     dashpush=0,
     xaxis=True,
 ):
     Artist.__init__(self)
     # The position (x,y) values for _mytext and dashline
     # are bogus as given in the instantiation; they will
     # be set correctly by update_coords() in draw()
     self._mytext = Text(
         x=x,
         y=y,
         text=text,
         color=color,
         verticalalignment=verticalalignment,
         horizontalalignment=horizontalalignment,
         multialignment=multialignment,
         fontproperties=fontproperties,
         rotation=rotation,
     )
     self.dashline = Line2D(xdata=(x, x),
                            ydata=(y, y),
                            color='k',
                            linestyle='-')
     self._x = x
     self._y = y
     self._dashlength = dashlength
     self._dashdirection = dashdirection
     self._dashrotation = dashrotation
     self._dashpad = dashpad
     self._dashpush = dashpush
Example #41
0
    def __init__(
            self,
            x=0,
            y=0,
            text='',
            color=None,  # defaults to rc params
            verticalalignment='bottom',
            horizontalalignment='left',
            multialignment=None,
            fontproperties=None,  # defaults to FontProperties()
            rotation=None,
            linespacing=None,
            **kwargs):
        """
        Create a :class:`~matplotlib.text.Text` instance at *x*, *y*
        with string *text*.

        Valid kwargs are
        %(Text)s
        """

        Artist.__init__(self)
        self.cached = maxdict(5)
        self._x, self._y = x, y

        if color is None: color = rcParams['text.color']
        if fontproperties is None: fontproperties = FontProperties()
        elif is_string_like(fontproperties):
            fontproperties = FontProperties(fontproperties)

        self.set_text(text)
        self.set_color(color)
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment
        self._rotation = rotation
        self._fontproperties = fontproperties
        self._bbox = None
        self._renderer = None
        if linespacing is None:
            linespacing = 1.2  # Maybe use rcParam later.
        self._linespacing = linespacing
        self.update(kwargs)
Example #42
0
    def __init__(self,
                 figsize   = None,  # defaults to rc figure.figsize
                 dpi       = None,  # defaults to rc figure.dpi
                 facecolor = None,  # defaults to rc figure.facecolor
                 edgecolor = None,  # defaults to rc figure.edgecolor
                 linewidth = 1.0,   # the default linewidth of the frame
                 frameon = True,
                 ):
        """
        paper size is a w,h tuple in inches
        DPI is dots per inch 
        """
        Artist.__init__(self)
        #self.set_figure(self)

        if figsize is None  : figsize   = rcParams['figure.figsize']
        if dpi is None      : dpi       = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']
        
        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point( Value(0), Value(0) )
        self.ur = Point( self.figwidth*self.dpi,
                         self.figheight*self.dpi )
        self.bbox = Bbox(self.ll, self.ur)
        self.frameon = frameon
        
        self.transFigure = get_bbox_transform( unit_bbox(), self.bbox) 


        
        self.figurePatch = Rectangle(
            xy=(0,0), width=1, height=1,
            facecolor=facecolor, edgecolor=edgecolor,
            linewidth=linewidth,
            )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.clf()
Example #43
0
    def __init__(self, fig,
                 cmap = None,
                 norm = None,
                 offsetx = 0,
                 offsety = 0,
                 origin=None,
                 ):

        """
        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1
        
        """
        Artist.__init__(self)
        cm.ScalarMappable.__init__(self, norm, cmap)
        if origin is None: origin = rcParams['image.origin']
        self.origin = origin
        self.figure = fig
        self.ox = offsetx
        self.oy = offsety
Example #44
0
    def __init__(self, parent, handles, labels, loc, isaxes=True):
        Artist.__init__(self)
        if is_string_like(loc) and not self.codes.has_key(loc):
            verbose.report_error(
                'Unrecognized location %s. Falling back on upper right; valid locations are\n%s\t'
                % (loc, '\n\t'.join(self.codes.keys())))
        if is_string_like(loc): loc = self.codes.get(loc, 1)

        if isaxes:  # parent is an Axes
            self.set_figure(parent.figure)
        else:  # parent is a Figure
            self.set_figure(parent)

        self.parent = parent
        self.set_transform(get_bbox_transform(unit_bbox(), parent.bbox))
        self._loc = loc

        # make a trial box in the middle of the axes.  relocate it
        # based on it's bbox
        left, upper = 0.5, 0.5
        if self.NUMPOINTS == 1:
            self._xdata = array([left + self.HANDLELEN * 0.5])
        else:
            self._xdata = linspace(left, left + self.HANDLELEN, self.NUMPOINTS)
        textleft = left + self.HANDLELEN + self.HANDLETEXTSEP
        self.texts = self._get_texts(labels, textleft, upper)
        self.handles = self._get_handles(handles, self.texts)

        left, top = self.texts[-1].get_position()
        HEIGHT = self._approx_text_height()
        bottom = top - HEIGHT
        left -= self.HANDLELEN + self.HANDLETEXTSEP + self.PAD
        self.legendPatch = Rectangle(
            xy=(left, bottom),
            width=0.5,
            height=HEIGHT * len(self.texts),
            facecolor='w',
            edgecolor='k',
        )
        self._set_artist_props(self.legendPatch)
        self._drawFrame = True
Example #45
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes
        self.major = Ticker()
        self.minor = Ticker()
        #class dummy:
        #    locator = None
        #    formatter = None
        #self.major = dummy()
        #self.minor = dummy()

        self.label = self._get_label()
        self.majorTicks = []
        self.minorTicks = []

        self.cla()
Example #46
0
    def __init__(self, ax, loc=None, bbox=None):

        Artist.__init__(self)

        if is_string_like(loc) and not self.codes.has_key(loc):
            verbose.report_error('Unrecognized location %s. Falling back on bottom; valid locations are\n%s\t' %(loc, '\n\t'.join(self.codes.keys())))
            loc = 'bottom'
        if is_string_like(loc): loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True
Example #47
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes
        self.major = Ticker()
        self.minor = Ticker()
        #class dummy:
        #    locator = None
        #    formatter = None
        #self.major = dummy()
        #self.minor = dummy()

        self.label = self._get_label()
        self.offsetText = self._get_offset_text()
        self.majorTicks = []
        self.minorTicks = []

        self.cla()
Example #48
0
 def __init__(self,
              x=0, y=0, text='',
              color=None,          # defaults to rc params
              verticalalignment='center',
              horizontalalignment='center',
              multialignment=None,
              fontproperties=None, # defaults to FontProperties()
              rotation=None,
              dashlength=0.0,
              dashdirection=0,
              dashrotation=None,
              dashpad=3,
              dashpush=0,
              xaxis=True,
              ):
     Artist.__init__(self)
     # The position (x,y) values for _mytext and dashline
     # are bogus as given in the instantiation; they will
     # be set correctly by update_coords() in draw()
     self._mytext = Text(
                   x=x, y=y, text=text,
                   color=color,
                   verticalalignment=verticalalignment,
                   horizontalalignment=horizontalalignment,
                   multialignment=multialignment,
                   fontproperties=fontproperties,
                   rotation=rotation,
                   )
     self.dashline = Line2D(xdata=(x, x),
                            ydata=(y, y),
                            color='k',
                            linestyle='-')
     self._x = x
     self._y = y
     self._dashlength = dashlength
     self._dashdirection = dashdirection
     self._dashrotation = dashrotation
     self._dashpad = dashpad
     self._dashpush = dashpush
Example #49
0
    def __init__(self, parent, handles, labels, loc, isaxes=True):
        Artist.__init__(self)
        if is_string_like(loc) and not self.codes.has_key(loc):
            verbose.report_error(
                "Unrecognized location %s. Falling back on upper right; valid locations are\n%s\t"
                % (loc, "\n\t".join(self.codes.keys()))
            )
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)

        if isaxes:  # parent is an Axes
            self.set_figure(parent.figure)
        else:  # parent is a Figure
            self.set_figure(parent)

        self.parent = parent
        self.set_transform(get_bbox_transform(unit_bbox(), parent.bbox))
        self._loc = loc

        # make a trial box in the middle of the axes.  relocate it
        # based on it's bbox
        left, upper = 0.5, 0.5
        if self.NUMPOINTS == 1:
            self._xdata = array([left + self.HANDLELEN * 0.5])
        else:
            self._xdata = linspace(left, left + self.HANDLELEN, self.NUMPOINTS)
        textleft = left + self.HANDLELEN + self.HANDLETEXTSEP
        self.texts = self._get_texts(labels, textleft, upper)
        self.handles = self._get_handles(handles, self.texts)

        left, top = self.texts[-1].get_position()
        HEIGHT = self._approx_text_height()
        bottom = top - HEIGHT
        left -= self.HANDLELEN + self.HANDLETEXTSEP + self.PAD
        self.legendPatch = Rectangle(
            xy=(left, bottom), width=0.5, height=HEIGHT * len(self.texts), facecolor="w", edgecolor="k"
        )
        self._set_artist_props(self.legendPatch)
        self._drawFrame = True
Example #50
0
    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 antialiased = None,
                 fill=1,
                 **kwargs
                 ):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self.fill = fill


        if len(kwargs): setp(self, **kwargs)
Example #51
0
    def __init__(
            self,
            figsize=None,  # defaults to rc figure.figsize
            dpi=None,  # defaults to rc figure.dpi
            facecolor=None,  # defaults to rc figure.facecolor
            edgecolor=None,  # defaults to rc figure.edgecolor
            linewidth=0.0,  # the default linewidth of the frame
            frameon=True,  # whether or not to draw the figure frame
            subplotpars=None,  # default to rc
    ):
        """
        *figsize*
            w,h tuple in inches
        *dpi*
            dots per inch
        *facecolor*
            the figure patch facecolor; defaults to rc ``figure.facecolor``
        *edgecolor*
            the figure patch edge color; defaults to rc ``figure.edgecolor``
        *linewidth*
            the figure patch edge linewidth; the default linewidth of the frame
        *frameon*
            if ``False``, suppress drawing the figure frame
        *subplotpars*
            a :class:`SubplotParams` instance, defaults to rc
        """
        Artist.__init__(self)

        self.callbacks = cbook.CallbackRegistry()

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self.dpi_scale_trans = Affine2D()
        self.dpi = dpi
        self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
        self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)

        self.frameon = frameon

        self.transFigure = BboxTransformTo(self.bbox)

        # the figurePatch name is deprecated
        self.patch = self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.patch)
        self.patch.set_aa(False)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = AxesStack()  # track all figure axes and current axes
        self.clf()
        self._cachedRenderer = None
Example #52
0
    def __init__(self, parent, handles, labels, loc,
                 isaxes=True,
                 numpoints = 4,      # the number of points in the legend line
                 prop = FontProperties(size='smaller'),
                 pad = 0.2,          # the fractional whitespace inside the legend border
                 markerscale = 0.6,    # the relative size of legend markers vs. original
                 # the following dimensions are in axes coords
                 labelsep = 0.005,     # the vertical space between the legend entries
                 handlelen = 0.05,     # the length of the legend lines
                 handletextsep = 0.02, # the space between the legend line and legend text
                 axespad = 0.02,       # the border between the axes and legend edge

                 shadow=False,
                 ):
        """
  parent                # the artist that contains the legend
  handles               # a list of artists (lines, patches) to add to the legend
  labels                # a list of strings to label the legend 
  loc                   # a location code
  isaxes=True           # whether this is an axes legend
  numpoints = 4         # the number of points in the legend line
  fontprop = FontProperties('smaller')  # the font property
  pad = 0.2             # the fractional whitespace inside the legend border
  markerscale = 0.6     # the relative size of legend markers vs. original
  shadow                # if True, draw a shadow behind legend 

The following dimensions are in axes coords
  labelsep = 0.005     # the vertical space between the legend entries
  handlelen = 0.05     # the length of the legend lines
  handletextsep = 0.02 # the space between the legend line and legend text
  axespad = 0.02       # the border between the axes and legend edge
        """
        Artist.__init__(self)
        if is_string_like(loc) and not self.codes.has_key(loc):
            verbose.report_error('Unrecognized location %s. Falling back on upper right; valid locations are\n%s\t' %(loc, '\n\t'.join(self.codes.keys())))
        if is_string_like(loc): loc = self.codes.get(loc, 1)
        
        self.numpoints = numpoints
        self.prop = prop
        self.fontsize = prop.get_size_in_points()
        self.pad = pad
        self.markerscale = markerscale
        self.labelsep = labelsep
        self.handlelen = handlelen
        self.handletextsep = handletextsep
        self.axespad = axespad
        self.shadow = shadow
        
        if isaxes:  # parent is an Axes
            self.set_figure(parent.figure)
        else:        # parent is a Figure
            self.set_figure(parent)

        self.parent = parent
        self.set_transform( get_bbox_transform( unit_bbox(), parent.bbox) )
        self._loc = loc   

        # make a trial box in the middle of the axes.  relocate it
        # based on it's bbox
        left, upper = 0.5, 0.5
        if self.numpoints == 1:
            self._xdata = array([left + self.handlelen*0.5])
        else:
            self._xdata = linspace(left, left + self.handlelen, self.numpoints)
        textleft = left+ self.handlelen+self.handletextsep
        self.texts = self._get_texts(labels, textleft, upper)
        self.handles = self._get_handles(handles, self.texts)
        
        left, top = self.texts[-1].get_position()
        HEIGHT = self._approx_text_height()
        bottom = top-HEIGHT
        left -= self.handlelen + self.handletextsep + self.pad
        self.legendPatch = Rectangle(
            xy=(left, bottom), width=0.5, height=HEIGHT*len(self.texts),
            facecolor='w', edgecolor='k',
            )
        self._set_artist_props(self.legendPatch)
        self._drawFrame = True
Example #53
0
    def __init__(self, parent, handles, labels,
                 loc = None,
                 numpoints = None,     # the number of points in the legend line
                 prop = None,
                 pad = None,           # the fractional whitespace inside the legend border
                 markerscale = None,   # the relative size of legend markers vs. original
                 # the following dimensions are in axes coords
                 labelsep = None,      # the vertical space between the legend entries
                 handlelen = None,     # the length of the legend lines
                 handletextsep = None, # the space between the legend line and legend text
                 axespad = None,       # the border between the axes and legend edge

                 shadow = None
                 ):
        """
  parent                # the artist that contains the legend
  handles               # a list of artists (lines, patches) to add to the legend
  labels                # a list of strings to label the legend
  loc                   # a location code
  numpoints = 4         # the number of points in the legend line
  prop = FontProperties(size='smaller')  # the font property
  pad = 0.2             # the fractional whitespace inside the legend border
  markerscale = 0.6     # the relative size of legend markers vs. original
  shadow                # if True, draw a shadow behind legend

The following dimensions are in axes coords
  labelsep = 0.005     # the vertical space between the legend entries
  handlelen = 0.05     # the length of the legend lines
  handletextsep = 0.02 # the space between the legend line and legend text
  axespad = 0.02       # the border between the axes and legend edge
        """
        from axes import Axes     # local import only to avoid circularity
        from figure import Figure # local import only to avoid circularity

        Artist.__init__(self)

        proplist=[numpoints, pad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow]
        propnames=['numpoints', 'pad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow']
        for name, value in safezip(propnames,proplist):
            if value is None:
                value=rcParams["legend."+name]
            setattr(self,name,value)
        if self.numpoints <= 0:
            raise ValueError("numpoints must be >= 0; it was %d"% numpoints)
        if prop is None:
            self.prop=FontProperties(size=rcParams["legend.fontsize"])
        else:
            self.prop=prop
        self.fontsize = self.prop.get_size_in_points()

        if isinstance(parent,Axes):
            self.isaxes = True
            self.set_figure(parent.figure)
        elif isinstance(parent,Figure):
            self.isaxes = False
            self.set_figure(parent)
        else:
            raise TypeError("Legend needs either Axes or Figure as parent")
        self.parent = parent
        self._offsetTransform = Affine2D()
        self._parentTransform = BboxTransformTo(parent.bbox)
        Artist.set_transform(self, self._offsetTransform + self._parentTransform)

        if loc is None:
            loc = rcParams["legend.loc"]
            if not self.isaxes and loc in [0,'best']:
                loc = 'upper right'
        if is_string_like(loc):
            if not self.codes.has_key(loc):
                if self.isaxes:
                    warnings.warn('Unrecognized location "%s". Falling back on "best"; '
                                  'valid locations are\n\t%s\n'
                                  % (loc, '\n\t'.join(self.codes.keys())))
                    loc = 0
                else:
                    warnings.warn('Unrecognized location "%s". Falling back on "upper right"; '
                                  'valid locations are\n\t%s\n'
                                   % (loc, '\n\t'.join(self.codes.keys())))
                    loc = 1
            else:
                loc = self.codes[loc]
        if not self.isaxes and loc == 0:
            warnings.warn('Automatic legend placement (loc="best") not implemented for figure legend. '
                          'Falling back on "upper right".')
            loc = 1

        self._loc = loc

        self.legendPatch = Rectangle(
            xy=(0.0, 0.0), width=0.5, height=0.5,
            facecolor='w', edgecolor='k',
            )
        self._set_artist_props(self.legendPatch)

        # make a trial box in the middle of the axes.  relocate it
        # based on it's bbox
        left, top = 0.5, 0.5
        textleft = left+ self.handlelen+self.handletextsep
        self.texts = self._get_texts(labels, textleft, top)
        self.legendHandles = self._get_handles(handles, self.texts)

        self._drawFrame = True