In [3]:
%matplotlib notebook
import matplotlib
from IPython.display import set_matplotlib_formats

#matplotlib.rcParams['figure.dpi'] = 150
set_matplotlib_formats('retina')
In [7]:
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0.005, 100, 1)

fig, ax = plt.subplots()
plt.ylim(ymin=-0.5, ymax=10)
plt.xlim(xmin=0, xmax=100)
plt.ylabel("Running Time (ms)")
plt.xlabel("Input Size ($N$)")
plt.xticks(np.arange(min(x), max(x)+1, 10.0))

ax.plot(x, (x/x) - 1, label='Constant', color='g')
ax.plot(x, x/10, label='Linear', color='b')
ax.plot(x, (x/10)*np.log(x/10), label='$N\logN$', color='r')
ax.plot(x, np.log(x/10), label='$\logN$', color='cyan')
ax.plot(x, (x/10)**3, label='$N^3$', color='m')
ax.plot(x, (x/10)**2+(x/10)+0, label='$N^4$', color='y')
ax.plot(x, 2**(x/10), label='$2^N$', color='darkcyan')



legend = plt.legend(loc='center right', fontsize='small')
plt.savefig("big-o-curves1.pdf")
plt.show()
In [2]:
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0.005, 10000, 1)

fig, ax = plt.subplots()
plt.ylim(ymin=-0.5, ymax=1)
plt.xlim(xmin=0, xmax=10000)
plt.ylabel("Running Time (ms)")
plt.xlabel("Input Size ($N$)")
ax.plot(x, (x/x)-0.8, label='Constant', color='g')
ax.plot(x, x/2000, label='Linear', color='b')
ax.plot(x, (x/150)*np.log(x/150), label='$N\logN$', color='r')
ax.plot(x, np.log(x/150), label='$\logN$', color='cyan')
ax.plot(x, (x/150)**3, label='Cubic', color='m')
ax.plot(x, (x/250)**2+(x/250)+0, label='Quadratic', color='y')

legend = plt.legend(loc='center right', fontsize='small')
plt.savefig("big-o-curves2.pdf")
plt.show()