def add_plot ( x , y , xl , yl , fig , ax , LATEX = False , linestyle = None , * * kwargs ) : if LATEX : xl_data = xl [ 1 ] # NOQA yl_data = yl [ 1 ] else : xl_data = xl [ 0 ] # NOQA yl_data = yl [ 0 ] for idx in range ( len ( y ) ) : ax . plot ( x , y [ idx ] , label = yl_data [ idx ] , linestyle = linestyle ) ax . legend ( loc = 'upper right' ) ax . set_ylim ( auto = True )
python legend with many lines
Add plots to an existing plot
def add_plot(x, y, xl, yl, fig, ax, LATEX=False, linestyle=None, **kwargs):
    """Add plots to an existing plot"""
    if LATEX:
        xl_data = xl[1]  # NOQA
        yl_data = yl[1]
    else:
        xl_data = xl[0]  # NOQA
        yl_data = yl[0]

    for idx in range(len(y)):
        ax.plot(x, y[idx], label=yl_data[idx], linestyle=linestyle)

    ax.legend(loc='upper right')
    ax.set_ylim(auto=True)