Skip to content
Snippets Groups Projects
Commit 9175c6d3 authored by Dominik Zobel's avatar Dominik Zobel
Browse files

Adjust plot for Big-O-notation and linestyle in plots generally

parent b8faf8bb
No related branches found
No related tags found
1 merge request!24complexity lecture
......@@ -33,17 +33,18 @@ import numpy as np
x = np.linspace(1, 25, 100)
plt.figure(dpi=200)
plt.plot(x, x**2, label=r"$\mathcal{O}(n^2)$")
plt.plot(x, x**2, label=r"$\mathcal{O}(n^2)$", ls="--")
plt.plot(x, 1 + x * np.log(x), label=r"$\mathcal{O}(n \log{n})$")
plt.plot(x, x, label=r"$\mathcal{O}(n)$")
plt.plot(x, 1+np.log(x), label=r"$\mathcal{O}(\log{n})$")
plt.plot(x, np.ones_like(x), label=r"$\mathcal{O}(1)$")
plt.plot(x, x, label=r"$\mathcal{O}(n)$", ls=":")
plt.plot(x, 1+np.log(x), label=r"$\mathcal{O}(\log{n})$", ls="-.")
plt.plot(x, np.ones_like(x), label=r"$\mathcal{O}(1)$", ls=(0, (5, 10)))
plt.xlabel("Number of elements n", fontsize=14)
plt.ylabel("Time or Space", fontsize=14)
plt.xlim(1, 25)
plt.ylim(0, 25)
plt.xticks([], [])
plt.yticks([], [])
plt.legend()
plt.legend(fontsize=16)
None
```
......@@ -492,7 +493,7 @@ y2 = get_times(fib2, x2, 3)
y3 = get_times(fib3, x3, 3)
plt.plot(x1, y1, label="fib1", color="C0", ls="--")
plt.plot(x2, y2, label="fib2", color="C1")
plt.plot(x3, y3, label="fib3", color="C2")
plt.plot(x3, y3, label="fib3", color="C2", ls=":")
plt.ylim(0, max(y2 + y3) * 1.05)
plt.xlabel("Number n", fontsize=14)
plt.ylabel("Time to compute / s", fontsize=14)
......@@ -511,7 +512,7 @@ y2 = get_times(fib2, x2, 3)
y3 = get_times(fib3, x3, 3)
plt.plot(x1, y1, label="fib1", color="C0", ls="--")
plt.plot(x2, y2, label="fib2", color="C1")
plt.plot(x3, y3, label="fib3", color="C2")
plt.plot(x3, y3, label="fib3", color="C2", ls=":")
plt.ylim(0, max(y2 + y3) * 1.05)
plt.xlabel("Number n", fontsize=14)
plt.ylabel("Time to compute / s", fontsize=14)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment