Example #1
0
    def __init__(self,
                 edgecolors=None,
                 facecolors=None,
                 linewidths=None,
                 antialiaseds = None,
                 offsets = None,
                 transOffset = identity_transform(),
                 norm = None,  # optional for ScalarMappable
                 cmap = None,  # ditto
                 ):
        Collection.__init__(self)
        ScalarMappable.__init__(self, norm, cmap)

        if edgecolors is None: edgecolors =\
           self._get_color(rcParams['patch.edgecolor'])
        if facecolors is None: facecolors = \
           self._get_color(rcParams['patch.facecolor'])
        if linewidths is None: linewidths = ( rcParams['patch.linewidth'],)
        if antialiaseds is None: antialiaseds = ( rcParams['patch.antialiased'],)

        self._edgecolors = edgecolors
        self._facecolors  = facecolors
        self._linewidths  = linewidths
        self._antialiaseds = antialiaseds
        self._offsets = offsets
        self._transOffset = transOffset
Example #2
0
    def __init__(self,
                 edgecolors=None,
                 facecolors=None,
                 linewidths=None,
                 antialiaseds = None,
                 offsets = None,
                 transOffset = identity_transform(),
                 norm = None,  # optional for ScalarMappable
                 cmap = None,  # ditto
                 ):
        Collection.__init__(self)
        ScalarMappable.__init__(self, norm, cmap)

        if edgecolors is None: edgecolors =\
           self._get_color(rcParams['patch.edgecolor'])
        if facecolors is None: facecolors = \
           self._get_color(rcParams['patch.facecolor'])
        if linewidths is None: linewidths = ( rcParams['patch.linewidth'],)
        if antialiaseds is None: antialiaseds = ( rcParams['patch.antialiased'],)

        self._edgecolors = edgecolors
        self._facecolors  = facecolors
        self._linewidths  = linewidths
        self._antialiaseds = antialiaseds
        self._offsets = offsets
        self._transOffset = transOffset
Example #3
0
    def __init__(self, segments,
                 linewidths    = None,
                 colors        = None,
                 antialiaseds  = None,
                 linestyle = 'solid',
                 offsets = None,
                 transOffset = None,#identity_transform(),
                 ):
        """
        segments is a sequence of ( line0, line1, line2), where
        linen = (x0, y0), (x1, y1), ... (xm, ym).
        Each line can be a different length.

        colors must be a tuple of RGBA tuples (eg arbitrary color
        strings, etc, not allowed).

        antialiaseds must be a sequence of ones or zeros

        linestyles is a string or dash tuple. Legal string values are
          solid|dashed|dashdot|dotted.  The dash tuple is (offset, onoffseq)
          where onoffseq is an even length tuple of on and off ink in points.

        If linewidths, colors, or antialiaseds is None, they default to
        their rc params setting, in sequence form.

        If offsets and transOffset are not None, then
        offsets are transformed by transOffset and applied after
        the segments have been transformed to display coordinates.

        If offsets is not None but transOffset is None, then the
        offsets are added to the segments before any transformation.
        In this case, a single offset can be specified as offsets=(xo,yo),
        and this value will be
        added cumulatively to each successive segment, so as
        to produce a set of successively offset curves.
        """

        Collection.__init__(self)

        if linewidths is None   :
            linewidths   = (rcParams['lines.linewidth'], )

        if colors is None       :
            colors       = self._get_color(rcParams['lines.color'])
        if antialiaseds is None :
            antialiaseds = (rcParams['lines.antialiased'], )

        self._segments = list(segments)
        self._colors = colors
        self._aa = antialiaseds
        self._lw = linewidths
        self.set_linestyle(linestyle)
        if transOffset is None:
            if offsets is not None:
                self._add_offsets(offsets)
                offsets = None
            transOffset = identity_transform()
        self._offsets = offsets
        self._transOffset = transOffset
Example #4
0
    def __init__(self):

        self.figure = None
        self._transform = identity_transform()
        self._transformSet = False
        self._visible = True
        self._alpha = 1.0
        self.clipbox = None
        self._clipon = False
        self._lod = False
Example #5
0
    def __init__(self):

        self.figure = None
        self._transform = identity_transform()
        self._transformSet = False
        self._visible = True
        self._alpha = 1.0
        self.clipbox = None
        self._clipon = False
        self._lod = False
Example #6
0
 def _get_offset_text(self):
     # x in display coords, y in axes coords (to be updated at draw time)
     offsetText = Text(x=0, y=0.5,
         fontproperties = FontProperties(size=rcParams['ytick.labelsize']),
         color = rcParams['ytick.color'],
         verticalalignment = 'bottom',
         horizontalalignment = 'left',
         )
     offsetText.set_transform(blend_xy_sep_transform(self.axes.transAxes,
                                                     identity_transform()) )
     self._set_artist_props(offsetText)
     self.offset_text_position='left'
     return offsetText
Example #7
0
 def _get_offset_text(self):
     # x in axes coords, y in display coords (to be updated at draw time)
     offsetText = Text(x=1, y=0,
         fontproperties = FontProperties(size=rcParams['tick.labelsize']),
         color = rcParams['tick.color'],
         verticalalignment='top',
         horizontalalignment='right',
         )
     offsetText.set_transform( blend_xy_sep_transform( self.axes.transAxes,
                                                  identity_transform() ))
     self._set_artist_props(offsetText)
     self.offset_text_position='bottom'
     return offsetText
Example #8
0
    def _get_label(self):
        # x in axes coords, y in display coords (to be updated at draw
        # time by _update_label_positions
        label = Text(x=0.5, y=0,  
            fontproperties = FontProperties(size=rcParams['axes.labelsize']),
            color = rcParams['axes.labelcolor'],
            verticalalignment='top',
            horizontalalignment='center',
            )
        label.set_transform( blend_xy_sep_transform( self.axes.transAxes,
                                                     identity_transform() ))

        self._set_artist_props(label)
        return label
Example #9
0
    def _get_label(self):
        # x in axes coords, y in display coords (to be updated at draw
        # time by _update_label_positions
        label = Text(x=0.5, y=0,  
            fontproperties = FontProperties(size=rcParams['axes.labelsize']),
            color = rcParams['axes.labelcolor'],
            verticalalignment='top',
            horizontalalignment='center',
            )
        label.set_transform( blend_xy_sep_transform( self.axes.transAxes,
                                                     identity_transform() ))

        self._set_artist_props(label)
        return label
Example #10
0
    def __init__(self):
        self.figure = None

        self._transform = identity_transform()
        self._transformSet = False
        self._visible = True
        self._alpha = 1.0
        self.clipbox = None
        self._clipon = False
        self._lod = False
        self._label = ''

        self.eventson = False  # fire events only if eventson
        self._oid = 0  # an observer id
        self._propobservers = {}  # a dict from oids to funcs
Example #11
0
    def __init__(self):
        self.figure = None

        self._transform = identity_transform()
        self._transformSet = False
        self._visible = True
        self._alpha = 1.0
        self.clipbox = None
        self._clipon = False
        self._lod = False
        self._label = ''

        self.eventson = False  # fire events only if eventson
        self._oid = 0  # an observer id
        self._propobservers = {} # a dict from oids to funcs
Example #12
0
    def _get_label(self):
        # x in display coords (updated by _update_label_position)
        # y in axes coords
        label = Text(x=0, y=0.5,
            # todo: get the label position
            fontproperties=FontProperties(size=rcParams['axes.labelsize']),
            color    = rcParams['axes.labelcolor'],
            verticalalignment='center',
            horizontalalignment='right',
            rotation='vertical', 
            )
        label.set_transform( blend_xy_sep_transform( identity_transform(),
                                                     self.axes.transAxes) )

        self._set_artist_props(label)
        return label
Example #13
0
    def _get_label(self):
        # x in display coords (updated by _update_label_position)
        # y in axes coords
        label = Text(x=0, y=0.5,
            # todo: get the label position
            fontproperties=FontProperties(size=rcParams['axes.labelsize']),
            color    = rcParams['axes.labelcolor'],
            verticalalignment='center',
            horizontalalignment='right',
            rotation='vertical', 
            )
        label.set_transform( blend_xy_sep_transform( identity_transform(),
                                                     self.axes.transAxes) )

        self._set_artist_props(label)
        return label
Example #14
0
    def __init__(
            self,
            edgecolors=None,
            facecolors=None,
            linewidths=None,
            antialiaseds=None,
            offsets=None,
            transOffset=identity_transform(),
            norm=None,  # optional for ScalarMappable
            cmap=None,  # ditto
    ):
        Collection.__init__(self)
        ScalarMappable.__init__(self, norm, cmap)

        if facecolors is None: facecolors = rcParams['patch.facecolor']
        if edgecolors is None: edgecolors = rcParams['patch.edgecolor']
        if linewidths is None: linewidths = (rcParams['patch.linewidth'], )
        if antialiaseds is None:
            antialiaseds = (rcParams['patch.antialiased'], )

        self._facecolors = colorConverter.to_rgba_list(facecolors)
        if edgecolors == 'None':
            self._edgecolors = self._facecolors
            linewidths = (0, )
        else:
            self._edgecolors = colorConverter.to_rgba_list(edgecolors)
        self._linewidths = linewidths
        self._antialiaseds = antialiaseds
        #self._offsets = offsets
        self._original_offsets = offsets
        self._cached_offsets = offsets
        self._transOffset = transOffset
        self._xunits = self._yunits = None
        self._update_cache = {
            '_original_offsets': None,
            '_xunits': None,
            '_yunits': None
        }
Example #15
0
    def __init__(self,
                 artist,
                 s,
                 loc=None,
                 padx='auto',
                 pady='auto',
                 autopad=3,
                 **props):
        """
        Annotate the matplotlib.Artist artist with string s.  kwargs
        props are passed on to the Text base class and are text
        properties.

        loc is an x, y tuple.  If the location codes are a string and
        the artist supports the
        "get_window_extent method" (eg matplotlib.patches.Patch and
        children, Text, Axes, Figure, Line2D) the location code can be
        a pair of strings

          A: 'inside left', 'inside upper'
          B: 'outside right', 'outside lower'
          C: 'center', 'center'
          D: 'inside left', 'outside bottom'
          E: 'center', 'outside top'
          inside and outside cannot be used with 'center'.  With
          upper, lower, left and right, inside will be assumed if
          inside|outside is not provided

                                  E
             --------------------------------------------
             | A                                        |
             |                                          |
             |                                          |
             |                     C                    |
             |                                          |
             |                                          |
             |                                          |
             |__________________________________________|
              D                                          B

        These codes also work with Axes and Figure instances
        Otherwise it must be an x,y pair which will use the artist's
        own transformation

        eg
        Annotation(rectangle, 'some text', loc=('center', 'outside top'), color='red', size=14)

        Annotation(axes, 'A', loc=('inside left', 'inside top'))

        padx and pady are number of points to pad the text in the x
        and y direction.  When used with string codes, 'auto' will pad
        autopad points in the appropriate direction given the
        inside/outside left/right/center bottom/top/center location
        codes
        """
        # we'll draw ourself after the artist we annotate by default
        zorder = props.get('zorder', artist.get_zorder() + 1)
        Text.__init__(self, text=s, **props)
        self.set_zorder(zorder)
        self.set_transform(identity_transform())
        self._loc = tuple(loc)
        self._padx, self._pady, self._autopad = padx, pady, autopad
        self._annotateArtist = artist
        # funcx and funcy  are used to place the x, y coords for
        # artists who define get_window_extent
        if is_string_like(
                self._loc[0]) and is_string_like(self._loc[1]) and hasattr(
                    self._annotateArtist, 'get_window_extent'):
            xloc, yloc = self._loc
            self._process_xloc(xloc)
            self._process_yloc(yloc)
        else:
            self._funcx = None
            self._funcy = None

        self._renderer = None
Example #16
0
    def __init__(
            self,
            segments,
            linewidths=None,
            colors=None,
            antialiaseds=None,
            linestyle='solid',
            offsets=None,
            transOffset=None,  #identity_transform(),
    ):
        """
        segments is a sequence of ( line0, line1, line2), where
        linen = (x0, y0), (x1, y1), ... (xm, ym).
        Each line can be a different length.

        colors must be a tuple of RGBA tuples (eg arbitrary color
        strings, etc, not allowed).

        antialiaseds must be a sequence of ones or zeros

        linestyles is a string or dash tuple. Legal string values are
          solid|dashed|dashdot|dotted.  The dash tuple is (offset, onoffseq)
          where onoffseq is an even length tuple of on and off ink in points.

        If linewidths, colors, or antialiaseds is None, they default to
        their rc params setting, in sequence form.

        If offsets and transOffset are not None, then
        offsets are transformed by transOffset and applied after
        the segments have been transformed to display coordinates.

        If offsets is not None but transOffset is None, then the
        offsets are added to the segments before any transformation.
        In this case, a single offset can be specified as offsets=(xo,yo),
        and this value will be
        added cumulatively to each successive segment, so as
        to produce a set of successively offset curves.
        """

        Collection.__init__(self)

        if linewidths is None:
            linewidths = (rcParams['lines.linewidth'], )

        if colors is None:
            colors = self._get_color(rcParams['lines.color'])
        if antialiaseds is None:
            antialiaseds = (rcParams['lines.antialiased'], )

        self._segments = list(segments)
        self._colors = colors
        self._aa = antialiaseds
        self._lw = linewidths
        self.set_linestyle(linestyle)
        if transOffset is None:
            if offsets is not None:
                self._add_offsets(offsets)
                offsets = None
            transOffset = identity_transform()
        self._offsets = offsets
        self._transOffset = transOffset
Example #17
0
    def __init__(self, artist, s, loc=None,
                 padx='auto', pady='auto', autopad=3, **props):
        """
        Annotate the matplotlib.Artist artist with string s.  kwargs
        props are passed on to the Text base class and are text
        properties.

        loc is an x, y tuple.  If the location codes are a string and
        the artist supports the
        "get_window_extent method" (eg matplotlib.patches.Patch and
        children, Text, Axes, Figure, Line2D) the location code can be
        a pair of strings

          A: 'inside left', 'inside upper'
          B: 'outside right', 'outside lower'
          C: 'center', 'center'
          D: 'inside left', 'outside bottom'
          E: 'center', 'outside top'
          inside and outside cannot be used with 'center'.  With
          upper, lower, left and right, inside will be assumed if
          inside|outside is not provided

                                  E
             --------------------------------------------
             | A                                        |
             |                                          |
             |                                          |
             |                     C                    |
             |                                          |
             |                                          |
             |                                          |
             |__________________________________________|
              D                                          B

        These codes also work with Axes and Figure instances
        Otherwise it must be an x,y pair which will use the artist's
        own transformation

        eg
        Annotation(rectangle, 'some text', loc=('center', 'outside top'), color='red', size=14)

        Annotation(axes, 'A', loc=('inside left', 'inside top'))

        padx and pady are number of points to pad the text in the x
        and y direction.  When used with string codes, 'auto' will pad
        autopad points in the appropriate direction given the
        inside/outside left/right/center bottom/top/center location
        codes
        """
        # we'll draw ourself after the artist we annotate by default
        zorder = props.get('zorder', artist.get_zorder() + 1)
        Text.__init__(self, text=s, **props)
        self.set_zorder(zorder)
        self.set_transform(identity_transform())
        self._loc = tuple(loc)
        self._padx, self._pady, self._autopad = padx, pady, autopad
        self._annotateArtist = artist
        # funcx and funcy  are used to place the x, y coords for
        # artists who define get_window_extent
        if is_string_like(self._loc[0]) and is_string_like(self._loc[1]) and hasattr(self._annotateArtist, 'get_window_extent'):
            xloc, yloc = self._loc
            self._process_xloc(xloc)
            self._process_yloc(yloc)
        else:
            self._funcx = None
            self._funcy = None

        self._renderer = None
Example #18
0
    def __init__(
        self,
        segments,  # Can be None.
        linewidths=None,
        colors=None,
        antialiaseds=None,
        linestyle='solid',
        offsets=None,
        transOffset=None,  #identity_transform(),
        norm=None,
        cmap=None,
    ):
        """
        segments is a sequence of ( line0, line1, line2), where
        linen = (x0, y0), (x1, y1), ... (xm, ym), or the
        equivalent numerix array with two columns.
        Each line can be a different length.

        colors must be a tuple of RGBA tuples (eg arbitrary color
        strings, etc, not allowed).

        antialiaseds must be a sequence of ones or zeros

        linestyles is a string or dash tuple. Legal string values are
          solid|dashed|dashdot|dotted.  The dash tuple is (offset, onoffseq)
          where onoffseq is an even length tuple of on and off ink in points.

        If linewidths, colors, or antialiaseds is None, they default to
        their rc params setting, in sequence form.

        If offsets and transOffset are not None, then
        offsets are transformed by transOffset and applied after
        the segments have been transformed to display coordinates.

        If offsets is not None but transOffset is None, then the
        offsets are added to the segments before any transformation.
        In this case, a single offset can be specified as offsets=(xo,yo),
        and this value will be
        added cumulatively to each successive segment, so as
        to produce a set of successively offset curves.

        norm = None,  # optional for ScalarMappable
        cmap = None,  # ditto

        The use of ScalarMappable is optional.  If the ScalarMappable
        matrix _A is not None (ie a call to set_array has been made), at
        draw time a call to scalar mappable will be made to set the colors.
        """

        Collection.__init__(self)
        ScalarMappable.__init__(self, norm, cmap)

        if linewidths is None:
            linewidths = (rcParams['lines.linewidth'], )

        if colors is None:
            colors = (rcParams['lines.color'], )
        if antialiaseds is None:
            antialiaseds = (rcParams['lines.antialiased'], )

        self._colors = colorConverter.to_rgba_list(colors)
        self._aa = antialiaseds
        self._lw = linewidths
        self.set_linestyle(linestyle)
        self._uniform_offsets = None
        if offsets is not None:
            offsets = asarray(offsets)
            if len(offsets.shape) == 1:
                offsets = offsets[newaxis, :]  # Make it Nx2.
        if transOffset is None:
            if offsets is not None:
                self._uniform_offsets = offsets
                offsets = None
            transOffset = identity_transform()
        self._offsets = offsets
        self._transOffset = transOffset
        self.set_segments(segments)
Example #19
0
 def get_transform(self):
     'return the Transformation instance used by this artist'
     if self._transform is None:
         self._transform = identity_transform()
     return self._transform