def plot_round_trip_lifetimes(round_trips, disp_amount=<NUM_LIT:16>, lsize=<NUM_LIT>, ax=None):
if ax is None:<EOL><INDENT>ax = plt.subplot()<EOL><DEDENT>symbols_sample = round_trips.symbol.unique()<EOL>np.random.seed(<NUM_LIT:1>)<EOL>sample = np.random.choice(round_trips.symbol.unique(), replace=False,<EOL>size=min(disp_amount, len(symbols_sample)))<EOL>sample_round_trips = round_trips[round_trips.symbol.isin(sample)]<EOL>symbol_idx = pd.Series(np.arange(len(sample)), index=sample)<EOL>for symbol, sym_round_trips in sample_round_trips.groupby('<STR_LIT>'):<EOL><INDENT>for _, row in sym_round_trips.iterrows():<EOL><INDENT>c = '<STR_LIT:b>' if row.long else '<STR_LIT:r>'<EOL>y_ix = symbol_idx[symbol] + <NUM_LIT><EOL>ax.plot([row['<STR_LIT>'], row['<STR_LIT>']],<EOL>[y_ix, y_ix], color=c,<EOL>linewidth=lsize, solid_capstyle='<STR_LIT>')<EOL><DEDENT><DEDENT>ax.set_yticks(range(disp_amount))<EOL>ax.set_yticklabels([utils.format_asset(s) for s in sample])<EOL>ax.set_ylim((-<NUM_LIT:0.5>, min(len(sample), disp_amount) - <NUM_LIT:0.5>))<EOL>blue = patches.Rectangle([<NUM_LIT:0>, <NUM_LIT:0>], <NUM_LIT:1>, <NUM_LIT:1>, color='<STR_LIT:b>', label='<STR_LIT>')<EOL>red = patches.Rectangle([<NUM_LIT:0>, <NUM_LIT:0>], <NUM_LIT:1>, <NUM_LIT:1>, color='<STR_LIT:r>', label='<STR_LIT>')<EOL>leg = ax.legend(handles=[blue, red], loc='<STR_LIT>',<EOL>frameon=True, framealpha=<NUM_LIT:0.5>)<EOL>leg.get_frame().set_edgecolor('<STR_LIT>')<EOL>ax.grid(False)<EOL>return ax<EOL>
Plots timespans and directions of a sample of round trip trades.

Parameters
----------
round_trips : pd.DataFrame
    DataFrame with one row per round trip trade.
    - See full explanation in round_trips.extract_round_trips
ax : matplotlib.Axes, optional
    Axes upon which to plot.

Returns
-------
ax : matplotlib.Axes
    The axes that were plotted on.