Skip to content

Instantly share code, notes, and snippets.

@gmyrianthous
Created April 20, 2022 21:17
Show Gist options
  • Save gmyrianthous/27106b51253ccea7985215a7a9252793 to your computer and use it in GitHub Desktop.
Save gmyrianthous/27106b51253ccea7985215a7a9252793 to your computer and use it in GitHub Desktop.
Asymptotic Time Complexity - Plot
import matplotlib.pyplot as plt
x = [1, 10]
y = [3, 6]
ax = plt.subplot(111)
ax.plot(x, y, '--')
plt.text(2, 3.1,'O(s)', rotation=45)
plt.axhline(y=5 , linestyle='dotted')
plt.text(1, 5.1,'O(1)')
# Remove x/y labels
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
# Remove top and right borders
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment