A histogram represents the frequency of the values in an array. The following code generates a histogram from a flattened array (Line 2). The x-axis is limited to a certain range (1500–2650, Line 4). Zero values in the dataset are ignored (Line 5). Labels from the y-axis are removed (Line 9).
def create_elo_chart():
elo = read_elo().flatten()
fig, ax = plt.subplots()
plt.xlim(xmin = 1500, xmax = 2650)
counts, bins = np.histogram(elo[elo != 0], 25)
plt.hist(bins[:-1], bins, weights = counts)
ax.set(xlabel='Elo rating')
ax.set_yticklabels([])
ax.grid()
fig.savefig('elo.png')
Code-Sprache: Python (python)
The code generates this histogram.
