from pylab import *
matplotlib.rcParams.update({'font.size': 20})
figure(figsize = (14, 10))
years = range(1978, 1991)
data = {
"Arcade": [10,15,25,26,27,20,15,9,10,11,12,13,15],
"Consoles": [5,7,10,12,14,14,5,1,2,4,8,10,8],
"Handhelds": [0,0,0,0,0,0,0,0,0,0,0,1,2],
"Computers": [0,0,0,0,1,3,6,4,3,2,2,3,5],
}
col = ["#D7F372", "#7FF0A4", "#47E2D9", "#80C9F2", "#C9A7DE", "#ED88A9"]
col = col[:4][::-1]
c = 0
bottom = zeros(len(years))
for t, d in data.items():
bar(years, d, label = t, color = col[c], bottom = bottom, width = .8)
bottom += d
c += 1
xlabel("Year")
ylabel("Billions USD")
title("Global revenues of the video game industry from 1978 to 1990")
# https://stackoverflow.com/questions/1726391/matplotlib-draw-grid-lines-behind-other-graph-elements
gca().set_axisbelow(True)
grid(axis = "y")
xticks(years, rotation = 40)
text(1987, -8, "Data from Bloomberg.com", size = 16)
# https://stackoverflow.com/questions/22263807/how-is-order-of-items-in-matplotlib-legend-determined
legend(*(
[ x[i] for i in [3, 2, 1, 0] ]
for x in plt.gca().get_legend_handles_labels()
), handletextpad = 0.75, loc = 'best')
axis([1977.4, 1990.6, 0, 45])
tight_layout()
savefig("Chart of the 1983 video game crash.svg")
show()