Пример #1
0
 def __init__(self, offsetbox, xy,
              xybox=None,
              xycoords='data',
              boxcoords=None,
              frameon=True, pad=0.4, # BboxPatch
              annotation_clip=None,
              box_alignment=(0.5, 0.5),
              bboxprops=None,
              arrowprops=None,
              fontsize=None,
              **kwargs):
     """
     *offsetbox* : OffsetBox instance
     *xycoords* : same as Annotation but can be a tuple of two
        strings which are interpreted as x and y coordinates.
     *boxcoords* : similar to textcoords as Annotation but can be a
        tuple of two strings which are interpreted as x and y
        coordinates.
     *box_alignment* : a tuple of two floats for a vertical and
        horizontal alignment of the offset box w.r.t. the *boxcoords*.
        The lower-left corner is (0.0) and upper-right corner is (1.1).
     other parameters are identical to that of Annotation.
     """
     self.offsetbox = offsetbox
     self.arrowprops = arrowprops
     self.set_fontsize(fontsize)
     if arrowprops is not None:
         self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5))
         self.arrow_patch = FancyArrowPatch((0, 0), (1,1),
                                            **self.arrowprops)
     else:
         self._arrow_relpos = None
         self.arrow_patch = None
     _AnnotationBase.__init__(self,
                              xy, xytext=xybox,
                              xycoords=xycoords, textcoords=boxcoords,
                              annotation_clip=annotation_clip)
     martist.Artist.__init__(self, **kwargs)
     self._box_alignment = box_alignment
     self.patch = FancyBboxPatch(
         xy=(0.0, 0.0), width=1., height=1.,
         facecolor='w', edgecolor='k',
         mutation_scale=self.prop.get_size_in_points(),
         snap=True
         )
     self.patch.set_boxstyle("square",pad=pad)
     if bboxprops:
         self.patch.set(**bboxprops)
     self._drawFrame =  frameon
Пример #2
0
    def __init__(
            self,
            offsetbox,
            xy,
            xybox=None,
            xycoords='data',
            boxcoords=None,
            frameon=True,
            pad=0.4,  # BboxPatch
            annotation_clip=None,
            box_alignment=(0.5, 0.5),
            bboxprops=None,
            arrowprops=None,
            fontsize=None,
            **kwargs):
        """
        *offsetbox* : OffsetBox instance

        *xycoords* : same as Annotation but can be a tuple of two
           strings which are interpreted as x and y coordinates.

        *boxcoords* : similar to textcoords as Annotation but can be a
           tuple of two strings which are interpreted as x and y
           coordinates.

        *box_alignment* : a tuple of two floats for a vertical and
           horizontal alignment of the offset box w.r.t. the *boxcoords*.
           The lower-left corner is (0.0) and upper-right corner is (1.1).

        other parameters are identical to that of Annotation.
        """
        self.offsetbox = offsetbox

        self.arrowprops = arrowprops

        self.set_fontsize(fontsize)

        if arrowprops is not None:
            self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5))
            self.arrow_patch = FancyArrowPatch((0, 0), (1, 1),
                                               **self.arrowprops)
        else:
            self._arrow_relpos = None
            self.arrow_patch = None

        _AnnotationBase.__init__(self,
                                 xy,
                                 xytext=xybox,
                                 xycoords=xycoords,
                                 textcoords=boxcoords,
                                 annotation_clip=annotation_clip)

        martist.Artist.__init__(self, **kwargs)

        #self._fw, self._fh = 0., 0. # for alignment
        self._box_alignment = box_alignment

        # frame
        self.patch = FancyBboxPatch(
            xy=(0.0, 0.0),
            width=1.,
            height=1.,
            facecolor='w',
            edgecolor='k',
            mutation_scale=self.prop.get_size_in_points(),
            snap=True)
        self.patch.set_boxstyle("square", pad=pad)
        if bboxprops:
            self.patch.set(**bboxprops)
        self._drawFrame = frameon