Skip to content

Instantly share code, notes, and snippets.

@CamDavidsonPilon
Last active October 4, 2017 18:39
Show Gist options
  • Save CamDavidsonPilon/9d9f968a9ef8cf83fe65d85c012c1dce to your computer and use it in GitHub Desktop.
Save CamDavidsonPilon/9d9f968a9ef8cf83fe65d85c012c1dce to your computer and use it in GitHub Desktop.
%pyplot
x = np.arange(32)
A = [5, 10, 14, 20, 24, 27]
B = [3, 4, 6, 7, 8]
C = [2, 12, 22]
plt.scatter(A, 3*np.ones_like(A), c='k', marker='X', lw=0.5)
plt.scatter(B, 2*np.ones_like(B), c='k', marker='X', lw=0.5)
plt.scatter(C, 1*np.ones_like(C), c='k', marker='X', lw=0.5)
plt.xlim(0, 32)
plt.xticks(range(0, 32, 5), ["0", "5", "10", "15", "20", "25", "Today"])
plt.ylim(0.5, 3.5)
plt.yticks(range(1, 4), ["C", "B", "A"])
plt.vlines(30, 0, 3.5, linestyle='--', lw=0.75)
plt.ylabel("Customer")
plt.xlabel("Time")
plt.title("Customer A, B, and C's purchase history")
%pyplot
x = np.arange(80)
A = [5, 35, 73]
plt.scatter(A, 2*np.ones_like(A), c='k', marker='X', lw=0.5, label="purchases")
plt.xlim(0, 80)
plt.xticks(list(range(0, 80, 10)), ["0", "10", "20", "30", "40", "50", "60", "Today"])
plt.yticks([2], [""])
plt.ylim(1.5, 2.5)
plt.vlines(70, 0, 3.5, linestyle='--', lw=0.75)
plt.vlines(65, 0, 3.5, linestyle='--', lw=0.75, color='r', label="30 day time-limit")
plt.legend(loc='upper left')
plt.ylabel("Customer")
plt.xlabel("Time")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment