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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter