MCPcopy Index your code
hub / github.com/plotly/plotly.py / crawl_legend

Method crawl_legend

plotly/matplotlylib/mplexporter/exporter.py:158–188  ·  view source on GitHub ↗

Recursively look through objects in legend children

(self, ax, legend)

Source from the content-addressed store, hash-verified

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"""

Callers 1

crawl_axMethod · 0.95

Calls 4

draw_patchMethod · 0.95
draw_textMethod · 0.95
draw_lineMethod · 0.95
draw_collectionMethod · 0.95

Tested by

no test coverage detected