Пример #1
0
    def draw(self, renderer):
        if not self.get_visible():
            return
        renderer.open_group(self.__name__)

        lower_interval = self.axes.xaxis.lower_interval
        upper_interval = self.axes.xaxis.upper_interval

        if self.gridline.get_visible and transforms.interval_contains(
                self.axes.xaxis.get_view_interval(), self.get_loc()):
            self.gridline.draw(renderer)

        if transforms.interval_contains(lower_interval, self.get_loc()):
            if self.tick1line.get_visible:
                self.tick1line.draw(renderer)
            if self.label1.get_visible:
                self.label1.draw(renderer)

        if transforms.interval_contains(upper_interval, self.get_loc()):
            if self.tick2line.get_visible:
                self.tick2line.draw(renderer)
            if self.label2.get_visible:
                self.label2.draw(renderer)

        renderer.close_group(self.__name__)
Пример #2
0
    def draw(self, renderer):
        if not self.get_visible():
            return
        renderer.open_group(self.__name__)

        lower_interval = self.axes.xaxis.lower_interval
        upper_interval = self.axes.xaxis.upper_interval

        if self.gridOn and transforms.interval_contains(
                self.axes.xaxis.get_view_interval(), self.get_loc()):
            self.gridline.draw(renderer)

        if transforms.interval_contains(lower_interval, self.get_loc()):
            if self.tick1On:
                self.tick1line.draw(renderer)
            if self.label1On:
                self.label1.draw(renderer)

        if transforms.interval_contains(upper_interval, self.get_loc()):
            if self.tick2On:
                self.tick2line.draw(renderer)
            if self.label2On:
                self.label2.draw(renderer)

        renderer.close_group(self.__name__)
Пример #3
0
 def draw(self, renderer):
     # When adding the callbacks with `stack.callback`, we fetch the current
     # visibility state of the artist with `get_visible`; the ExitStack will
     # restore these states (`set_visible`) at the end of the block (after
     # the draw).
     with ExitStack() as stack:
         for artist in [
                 self.gridline,
                 self.tick1line,
                 self.tick2line,
                 self.label1,
                 self.label2,
         ]:
             stack.callback(artist.set_visible, artist.get_visible())
         needs_lower = transforms.interval_contains(self.axes.lower_xlim,
                                                    self.get_loc())
         needs_upper = transforms.interval_contains(self.axes.upper_xlim,
                                                    self.get_loc())
         self.tick1line.set_visible(self.tick1line.get_visible()
                                    and needs_lower)
         self.label1.set_visible(self.label1.get_visible() and needs_lower)
         self.tick2line.set_visible(self.tick2line.get_visible()
                                    and needs_upper)
         self.label2.set_visible(self.label2.get_visible() and needs_upper)
         super().draw(renderer)
Пример #4
0
    def draw(self, renderer, *args, **kwargs):
        'Draw the axis lines, grid lines, tick lines and labels'
        ticklabelBoxes = []
        ticklabelBoxes2 = []

        if not self.get_visible(): return
        renderer.open_group(__name__)
        interval = self.get_view_interval()
        for tick, loc, label in self.iter_ticks():
            if tick is None: continue
            if transforms.interval_contains(interval, loc):
                tick.set_label1(label)
                tick.set_label2(label)
            tick.update_position(loc)
            tick.draw(renderer)
            if tick.label1On and tick.label1.get_visible():
                extent = tick.label1.get_window_extent(renderer)
                ticklabelBoxes.append(extent)
            if tick.label2On and tick.label2.get_visible():
                extent = tick.label2.get_window_extent(renderer)
                ticklabelBoxes2.append(extent)

        # scale up the axis label box to also find the neighbors, not
        # just the tick labels that actually overlap note we need a
        # *copy* of the axis label box because we don't wan't to scale
        # the actual bbox

        self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

        self.label.draw(renderer)

        self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes2)
        self.offsetText.set_text( self.major.formatter.get_offset() )
        self.offsetText.draw(renderer)
Пример #5
0
def get_major_ticks_within_view_interval(axis):
    interval = axis.get_view_interval()
    ticks_in_view_interval = []
    for tick, loc in zip(axis.get_major_ticks(), axis.get_major_locator()()):
        if mtransforms.interval_contains(interval, loc):
            ticks_in_view_interval.append(tick)
    return ticks_in_view_interval
Пример #6
0
def get_major_ticks_within_view_interval(axis):
    interval = axis.get_view_interval()
    ticks_in_view_interval = []
    for tick, loc in zip(axis.get_major_ticks(),
                         axis.get_major_locator()()):
        if mtransforms.interval_contains(interval, loc):
            ticks_in_view_interval.append(tick)
    return ticks_in_view_interval
Пример #7
0
 def draw(self, renderer):
     with ExitStack() as stack:
         for artist in [
                 self.gridline, self.tick1line, self.tick2line, self.label1,
                 self.label2
         ]:
             stack.callback(artist.set_visible, artist.get_visible())
         needs_lower = transforms.interval_contains(self.axes.lower_xlim,
                                                    self.get_loc())
         needs_upper = transforms.interval_contains(self.axes.upper_xlim,
                                                    self.get_loc())
         self.tick1line.set_visible(self.tick1line.get_visible()
                                    and needs_lower)
         self.label1.set_visible(self.label1.get_visible() and needs_lower)
         self.tick2line.set_visible(self.tick2line.get_visible()
                                    and needs_upper)
         self.label2.set_visible(self.label2.get_visible() and needs_upper)
         super().draw(renderer)
Пример #8
0
 def draw(self, renderer):
     with ExitStack() as stack:
         for artist in [self.gridline, self.tick1line, self.tick2line,
                        self.label1, self.label2]:
             stack.callback(artist.set_visible, artist.get_visible())
         needs_lower = transforms.interval_contains(
             self.axes.lower_xlim, self.get_loc())
         needs_upper = transforms.interval_contains(
             self.axes.upper_xlim, self.get_loc())
         self.tick1line.set_visible(
             self.tick1line.get_visible() and needs_lower)
         self.label1.set_visible(
             self.label1.get_visible() and needs_lower)
         self.tick2line.set_visible(
             self.tick2line.get_visible() and needs_upper)
         self.label2.set_visible(
             self.label2.get_visible() and needs_upper)
         super(SkewXTick, self).draw(renderer)
Пример #9
0
 def draw(self, renderer):
     # When adding the callbacks with `stack.callback`, we fetch the current
     # visibility state of the artist with `get_visible`; the ExitStack will
     # restore these states (`set_visible`) at the end of the block (after
     # the draw).
     with ExitStack() as stack:
         for artist in [self.gridline, self.tick1line, self.tick2line,
                        self.label1, self.label2]:
             stack.callback(artist.set_visible, artist.get_visible())
         needs_lower = transforms.interval_contains(
             self.axes.lower_xlim, self.get_loc())
         needs_upper = transforms.interval_contains(
             self.axes.upper_xlim, self.get_loc())
         self.tick1line.set_visible(
             self.tick1line.get_visible() and needs_lower)
         self.label1.set_visible(
             self.label1.get_visible() and needs_lower)
         self.tick2line.set_visible(
             self.tick2line.get_visible() and needs_upper)
         self.label2.set_visible(
             self.label2.get_visible() and needs_upper)
         super(SkewXTick, self).draw(renderer)
Пример #10
0
def get_major_ticks_within_view_interval(axis): 
    """ Function shamelessly taken from:
            http://www.nabble.com/eliminating-the-top-tick-on-an-axis-to19446256.html#a19446256

        but the return now is the locations, not the ticks
        which seems to work better with AxesGrids.
    """
    interval = axis.get_view_interval() 

    locs = [] 
    for tick, loc in zip(axis.get_major_ticks(), 
                         axis.get_major_locator()()): 
        if mtransforms.interval_contains(interval, loc): 
            locs.append(loc) 
    return locs
Пример #11
0
 def gridOn(self):
     return (self._gridOn and (self._has_default_loc() or
             transforms.interval_contains(self.get_view_interval(),
                                          self.get_loc())))
Пример #12
0
 def _need_upper(self):
     return (self._has_default_loc() or
             transforms.interval_contains(self.axes.upper_xlim,
                                          self.get_loc()))
Пример #13
0
 def grid_in_bounds(self):
     """Whether any of the tick grid line is in bounds."""
     return transforms.interval_contains(
         self.axes.xaxis.get_view_interval(), self.get_loc())
Пример #14
0
 def upper_in_bounds(self):
     """Whether the upper part of the tick is in bounds."""
     return transforms.interval_contains(self.axes.upper_xlim,
                                         self.get_loc())
Пример #15
0
 def gridOn(self):  # noqa: N802
     """Control whether the gridline is drawn for this tick."""
     return (self._gridOn
             and (self._has_default_loc() or transforms.interval_contains(
                 self.get_view_interval(), self.get_loc())))
Пример #16
0
 def gridOn(self):  # noqa: N802
     """Control whether the gridline is drawn for this tick."""
     return (self._gridOn and (self._has_default_loc()
             or transforms.interval_contains(self.get_view_interval(), self.get_loc())))