| 57 | |
| 58 | |
| 59 | class SimpleAxisArtist(Artist): |
| 60 | def __init__(self, axis, axisnum, spine): |
| 61 | self._axis = axis |
| 62 | self._axisnum = axisnum |
| 63 | self.line = spine |
| 64 | |
| 65 | if isinstance(axis, XAxis): |
| 66 | self._axis_direction = ["bottom", "top"][axisnum-1] |
| 67 | elif isinstance(axis, YAxis): |
| 68 | self._axis_direction = ["left", "right"][axisnum-1] |
| 69 | else: |
| 70 | raise ValueError( |
| 71 | f"axis must be instance of XAxis or YAxis, but got {axis}") |
| 72 | super().__init__() |
| 73 | |
| 74 | @property |
| 75 | def major_ticks(self): |
| 76 | tickline = "tick%dline" % self._axisnum |
| 77 | return SimpleChainedObjects([getattr(tick, tickline) |
| 78 | for tick in self._axis.get_major_ticks()]) |
| 79 | |
| 80 | @property |
| 81 | def major_ticklabels(self): |
| 82 | label = "label%d" % self._axisnum |
| 83 | return SimpleChainedObjects([getattr(tick, label) |
| 84 | for tick in self._axis.get_major_ticks()]) |
| 85 | |
| 86 | @property |
| 87 | def label(self): |
| 88 | return self._axis.label |
| 89 | |
| 90 | def set_visible(self, b): |
| 91 | self.toggle(all=b) |
| 92 | self.line.set_visible(b) |
| 93 | self._axis.set_visible(True) |
| 94 | super().set_visible(b) |
| 95 | |
| 96 | def set_label(self, txt): |
| 97 | self._axis.set_label_text(txt) |
| 98 | |
| 99 | def toggle(self, all=None, ticks=None, ticklabels=None, label=None): |
| 100 | |
| 101 | if all: |
| 102 | _ticks, _ticklabels, _label = True, True, True |
| 103 | elif all is not None: |
| 104 | _ticks, _ticklabels, _label = False, False, False |
| 105 | else: |
| 106 | _ticks, _ticklabels, _label = None, None, None |
| 107 | |
| 108 | if ticks is not None: |
| 109 | _ticks = ticks |
| 110 | if ticklabels is not None: |
| 111 | _ticklabels = ticklabels |
| 112 | if label is not None: |
| 113 | _label = label |
| 114 | |
| 115 | if _ticks is not None: |
| 116 | tickparam = {f"tick{self._axisnum}On": _ticks} |
no outgoing calls
no test coverage detected
searching dependent graphs…