basic plot

PHOTO EMBED

Fri Apr 09 2021 18:38:08 GMT+0000 (Coordinated Universal Time)

Saved by @LC117

def plot_benchmark(x, y, title, x_label="dataset size", y_label="avg. time in s"):
    """
    Based on: mlinspect/experiments/performance/performance_benchmarks.ipynb
    """
    figure, axis = plt.subplots()

    axis.set_yscale('log')  # sets the scale to be logarithmic with powers of 10

    axis.plot(y, marker='8', color='blue', markersize=3)
    # for marker type see: https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers
    # plot function: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.plot.html#matplotlib.axes.Axes.plot
    # first arguments set y_value range , x is set to 0..N-1 for now

    axis.set_xticks(range(0, len(x)))
    axis.set_xticklabels(x)
    # set values regarding x - tick stand for 'small vertical lines' on the x-Axis

    axis.set_facecolor('white')
    axis.axis('equal')
    axis.set(xlabel=x_label, ylabel=y_label)
    axis.grid(True, color='lightgrey')

    figure.savefig("./benchmark_plots/" + title + ".png", bbox_inches='tight', dpi=800)

    plt.show()

    return
content_copyCOPY

https://github.com/stefan-grafberger/mlinspect/blob/19ca0d6ae8672249891835190c9e2d9d3c14f28f/experiments/performance/performance_benchmarks.ipynb