pyplot histogram labels in center

Solutions on MaxInterview for pyplot histogram labels in center by the best coders in the world

showing results for - "pyplot histogram labels in center"
Gaia
19 Sep 2016
1import numpy as np
2from matplotlib import pyplot as plt
3plt.rcParams["figure.figsize"] = [7.50, 3.50]
4plt.rcParams["figure.autolayout"] = True
5x = np.random.randn(1000)
6n_bins = 10
7n, bins, patches = plt.hist(x, bins=n_bins, edgecolor='black')
8ticks = [(patch._x0 + patch._x1)/2 for patch in patches]
9ticklabels = [i for i in range(n_bins)]
10plt.xticks(ticks, ticklabels)
11plt.show()
12
13# Check source below for the Graph