Recursively look through objects in legend children
(self, ax, legend)
| 156 | self.crawl_legend(ax, legend) |
| 157 | |
| 158 | def crawl_legend(self, ax, legend): |
| 159 | """ |
| 160 | Recursively look through objects in legend children |
| 161 | """ |
| 162 | legendElements = list( |
| 163 | utils.iter_all_children(legend._legend_box, skipContainers=True) |
| 164 | ) |
| 165 | legendElements.append(legend.legendPatch) |
| 166 | for child in legendElements: |
| 167 | # force a large zorder so it appears on top |
| 168 | child.set_zorder(1e6 + child.get_zorder()) |
| 169 | |
| 170 | # reorder border box to make sure marks are visible |
| 171 | if isinstance(child, matplotlib.patches.FancyBboxPatch): |
| 172 | child.set_zorder(child.get_zorder() - 1) |
| 173 | |
| 174 | try: |
| 175 | # What kind of object... |
| 176 | if isinstance(child, matplotlib.patches.Patch): |
| 177 | self.draw_patch(ax, child, force_trans=ax.transAxes) |
| 178 | elif isinstance(child, matplotlib.text.Text): |
| 179 | if child.get_text() != "None": |
| 180 | self.draw_text(ax, child, force_trans=ax.transAxes) |
| 181 | elif isinstance(child, matplotlib.lines.Line2D): |
| 182 | self.draw_line(ax, child, force_trans=ax.transAxes) |
| 183 | elif isinstance(child, matplotlib.collections.Collection): |
| 184 | self.draw_collection(ax, child, force_pathtrans=ax.transAxes) |
| 185 | else: |
| 186 | warnings.warn("Legend element %s not impemented" % child) |
| 187 | except NotImplementedError: |
| 188 | warnings.warn("Legend element %s not impemented" % child) |
| 189 | |
| 190 | def draw_line(self, ax, line, force_trans=None): |
| 191 | """Process a matplotlib line and call renderer.draw_line""" |
no test coverage detected