def make_figure_8_plot(logfile):
"""Generate high quality plot of data to reproduce figure 8.
The logfile is a CSV of the format [congestion_control, loss_rate, goodput, rtt, capacity, specified_bw]
"""
results = {}
plt.figure()
cubic = {"loss": [], "goodput": []}
bbr = {"loss": [], "goodput": []}
# For available options on plot() method, see: https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot
# We prefer to use explicit keyword syntax to help code readability.
# Create a figure.
fig_width = 8
fig_height = 5
fig, axes = plt.subplots(figsize=(fig_width, fig_height))
results = parse_results_csv(logfile)
xmark_ticks = get_loss_percent_xmark_ticks(results)
cubic = results['cubic']
bbr = results['bbr']
debug_print_verbose("CUBIC: %s" % cubic)
debug_print_verbose("BBR: %s" % bbr)
matplotlib.rcParams.update({'figure.autolayout': True})
plt.plot(cubic['loss'], cubic['goodput'], color='blue', linestyle='solid', marker='o',
markersize=7, label='CUBIC')
plt.plot(bbr['loss'], bbr['goodput'], color='red', linestyle='solid', marker='x',
markersize=7, label='BBR')
# Plot ideal line of (1-lossRate * BW)
ideal = {}
ideal['loss'] = cubic['loss']
ideal['goodput'] = [(1 - (x / 100.0)) * 100 for x in ideal['loss']]
plt.plot(ideal['loss'], ideal['goodput'], color='black', linestyle='dotted', label='ideal')
plt.xscale('log')
plot_titles(plt, xaxis="Loss Rate (%) - Log Scale", yaxis="Goodput (Mbps)")
apply_axes_formatting(axes, deduplicate_xmark_ticks(xmark_ticks))
plot_legend(plt, axes, ncol=3)
save_figure(plt, name="figures/figure8.png")
评论列表
文章目录