from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
plt.rc('figure', figsize=(12, 10))
The idea of stack plots is to show "parts to the whole" over time. A stack plot is basically like a pie-chart, only over time.
minutes = [1, 2, 3, 4, 5, 6, 7, 8, 9]
player1 = [1, 2, 3, 3, 4, 4, 4, 4, 5]
player2 = [1, 1, 1, 1, 2, 2, 2, 3, 4]
player3 = [1, 1, 1, 2, 2, 2, 3, 3, 3]
# Colors:
# Blue = #008fd5
# Red = #fc4f30
# Yellow = #e5ae37
# Green = #6d904f
# plt.pie([1, 1, 1], labels=["Player 1", "Player2", "Player3"])
labels = ['player1', 'player2', 'player3']
colors = ['#008fd5','#fc4f30', '#6d904f']
plt.stackplot(minutes, player1, player2, player3, labels=labels, colors=colors)
plt.legend(loc='upper left')
plt.title("My Awesome Stack Plot")
plt.tight_layout()
plt.show()
# example of project - tracking progreee daily for total of 8 hours
days = [1, 2, 3, 4, 5, 6, 7, 8, 9]
developer1 = [8, 6, 5, 5, 4, 2, 1, 1, 0]
developer2 = [0, 1, 2, 2, 2, 4, 4, 4, 4]
developer3 = [0, 1, 1, 1, 2, 2, 3, 3, 4]
labels = ['developer1', 'developer2', 'developer3']
colors = ['#008fd5','#fc4f30', '#6d904f']
plt.stackplot(days, developer1, developer2, developer3, labels=labels, colors=colors)
plt.legend(loc=(0.07, 0.02))
plt.title("My Awesome Stack Plot")
plt.xlabel('days')
plt.ylabel('hours')
plt.tight_layout()
plt.show()