Пример #1
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
Пример #2
0
 def get_window_extent(self, renderer):
     """
     Get the axes bounding box in display space.
     Subclasses should override for inclusion in the bounding box
     "tight" calculation. Default is to return an empty bounding
     box at 0, 0.
     """
     return Bbox([[0, 0], [0, 0]])
Пример #3
0
 def get_window_extent(self, renderer):
     bbox = Bbox([[0, 0], [0, 0]])
     trans_data_to_xy = self.get_transform().transform
     bbox.update_from_data_xy(trans_data_to_xy(self.get_xydata()),
                              ignore=True)
     # correct for marker size, if any
     if self._marker:
         ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5
         bbox = bbox.padded(ms)
     return bbox
Пример #4
0
    def get_extents(self, transform=None):
        """
        Returns the extents (xmin, ymin, xmax, ymax) of the path.

        Unlike computing the extents on the vertices alone, this
        algorithm will take into account the curves and deal with
        control points appropriately.
        """
        from transforms import Bbox
        if transform is not None:
            transform = transform.frozen()
        return Bbox(get_path_extents(self, transform))
Пример #5
0
    def get_extents(self, transform=None):
        """
        Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the
        path.

        Unlike computing the extents on the *vertices* alone, this
        algorithm will take into account the curves and deal with
        control points appropriately.
        """
        from transforms import Bbox
        path = self
        if transform is not None:
            transform = transform.frozen()
            if not transform.is_affine:
                path = self.transformed(transform)
                transform = None
        return Bbox(get_path_extents(path, transform))
Пример #6
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()