deploy/scripts/plottools/plottools.py
def savelegend(fig, ax, path, detect_codes=False, **kwargs):
    """
    detect_codes: prepend labels with style codes detected from lines
    """
    figleg, axleg = plt.subplots()
    handles, labels = ax.get_legend_handles_labels()
    if detect_codes:
        labels = [
            code_to_str(line_to_code(h)) + ' ' + l
            for h, l in zip(handles, labels)
        ]
    legend = axleg.legend(handles,
                          labels,
                          loc='center',
                          frameon=False,
                          handlelength=2.68)
    axleg.axis('off')
    figleg.canvas.draw()
    bbox = legend.get_window_extent().transformed(
        fig.dpi_scale_trans.inverted())
    # FIXME workaround for many lines (>5), incorrect box size
    dy = bbox.y1 - bbox.y0
    bbox.y0 -= dy * 0.022
    bbox.y1 += dy * 0.022
    savefig(figleg, path, bbox_inches=bbox, **kwargs)

    detect_codes: prepend labels with style codes detected from lines
    
prepend labels with style codes detected from lines
prepend labels with style codes detected from lines
def savelegend(fig, ax, path, detect_codes=False, **kwargs):
    figleg, axleg = plt.subplots()
    handles, labels = ax.get_legend_handles_labels()
    if detect_codes:
        labels = [
            code_to_str(line_to_code(h)) + ' ' + l
            for h, l in zip(handles, labels)
        ]
    legend = axleg.legend(handles,
                          labels,
                          loc='center',
                          frameon=False,
                          handlelength=2.68)
    axleg.axis('off')
    figleg.canvas.draw()
    bbox = legend.get_window_extent().transformed(
        fig.dpi_scale_trans.inverted())
    dy = bbox.y1 - bbox.y0
    bbox.y0 -= dy * 0.022
    bbox.y1 += dy * 0.022
    savefig(figleg, path, bbox_inches=bbox, **kwargs)
def savelegend ( fig , ax , path , detect_codes = False , ** kwargs ) : figleg , axleg = plt . subplots ( ) handles , labels = ax . get_legend_handles_labels ( ) if detect_codes : labels = [ code_to_str ( line_to_code ( h ) ) + ' ' + l for h , l in zip ( handles , labels ) ] legend = axleg . legend ( handles , labels , loc = 'center' , frameon = False , handlelength = 2.68 ) axleg . axis ( 'off' ) figleg . canvas . draw ( ) bbox = legend . get_window_extent ( ) . transformed ( fig . dpi_scale_trans . inverted ( ) ) dy = bbox . y1 - bbox . y0 bbox . y0 -= dy * 0.022 bbox . y1 += dy * 0.022 savefig ( figleg , path , bbox_inches = bbox , ** kwargs )
detect_codes: prepend labels with style codes detected from lines
detect_codes : prepend labels with style codes detected from lines
"""
    detect_codes: prepend labels with style codes detected from lines
    """ # FIXME workaround for many lines (>5), incorrect box size
fig
ax
path
detect_codes