def draw(self, renderer):
if not self.get_visible(): return<EOL>self._update_legend_box(renderer)<EOL>renderer.open_group('<STR_LIT>')<EOL>if self._loc == <NUM_LIT:0>:<EOL><INDENT>_findoffset = self._findoffset_best<EOL><DEDENT>else:<EOL><INDENT>_findoffset = self._findoffset_loc<EOL><DEDENT>def findoffset(width, height, xdescent, ydescent):<EOL><INDENT>return _findoffset(width, height, xdescent, ydescent, renderer)<EOL><DEDENT>self._legend_box.set_offset(findoffset)<EOL>fontsize = renderer.points_to_pixels(self.fontsize)<EOL>if self._mode in ["<STR_LIT>"]:<EOL><INDENT>pad = <NUM_LIT:2>*(self.borderaxespad+self.borderpad)*fontsize<EOL>self._legend_box.set_width(self.parent.bbox.width-pad)<EOL><DEDENT>if self._drawFrame:<EOL><INDENT>bbox = self._legend_box.get_window_extent(renderer)<EOL>self.legendPatch.set_bounds(bbox.x0, bbox.y0,<EOL>bbox.width, bbox.height)<EOL>self.legendPatch.set_mutation_scale(fontsize)<EOL>if self.shadow:<EOL><INDENT>shadow = Shadow(self.legendPatch, <NUM_LIT:2>, -<NUM_LIT:2>)<EOL>shadow.draw(renderer)<EOL><DEDENT>self.legendPatch.draw(renderer)<EOL><DEDENT>self._legend_box.draw(renderer)<EOL>renderer.close_group('<STR_LIT>')<EOL>
Draw everything that belongs to the legend