Skip to content

Instantly share code, notes, and snippets.

@egeucak
Created March 22, 2017 11:26
Show Gist options
  • Select an option

  • Save egeucak/8dff0834e454d6b6b5e2bb2e0884e24b to your computer and use it in GitHub Desktop.

Select an option

Save egeucak/8dff0834e454d6b6b5e2bb2e0884e24b to your computer and use it in GitHub Desktop.
This snippet draws graphs of value-N pairs
import numpy as np
import matplotlib.pyplot as plt
secLrg = [0.025, 0.028, 0.037, 0.025, 0.015, 0.015, 0.017, 0.019, 0.018, 0.02, 0.022, 0.024]
stoogeSort = [1.209, 6.693, 61.367, 60.985, 572.152, 561.977, 561.418, 1758.238, 1714.37, 1679.472, 1706.354, 4863.038]
radixSort = [0.084, 0.118, 0.093, 0.139, 0.216, 0.265, 0.354, 0.313, 0.165, 0.182, 0.189, 0.211]
shakerSort = [0.019, 0.127, 0.147, 0.187, 0.447, 0.539, 0.285, 0.384, 0.357, 0.391, 0.501, 0.587]
maximumSub = [0.016, 0.123, 0.135, 0.106, 0.242, 0.305, 0.209, 0.257, 0.25, 0.312, 0.363, 0.441]
sizes = [100,300,500,700,1100,1300,1500,1700,1900,2100,2300,2500]
algos = {"secLrg":secLrg, "stooge":stoogeSort, "radix": radixSort, "shaker":shakerSort, "maxSub":maximumSub}
sizeLen = len(sizes)
print(sizeLen)
for dict in algos.keys():
liste = algos[dict]
plt.plot(range(len(sizes)), algos[dict], label=dict)
plt.xticks(np.arange(sizeLen), sizes)
plt.xlabel("Sizes")
plt.ylabel("Times in Miliseconds")
plt.savefig("{}.png".format(dict))
plt.clf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment