Answers for "pyplot histogram labels in center"

0

pyplot histogram labels in center

import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.random.randn(1000)
n_bins = 10
n, bins, patches = plt.hist(x, bins=n_bins, edgecolor='black')
ticks = [(patch._x0 + patch._x1)/2 for patch in patches]
ticklabels = [i for i in range(n_bins)]
plt.xticks(ticks, ticklabels)
plt.show()

# Check source below for the Graph
Posted by: Guest on September-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language