import numpy as np
import matplotlib.pyplot as plt
# Generate random data
data = np.random.normal(0, 1, 1000)
# Create histogram with customizations
plt.hist(data, bins=20, alpha=0.5,
edgecolor='black', color='green',
range=(-3, 3), density=True)
# Add labels and title to the plot
plt.xlabel('Values')
plt.ylabel('Density')
plt.title('Histogram of Data')
# Add a grid to the plot
plt.grid(axis='y', alpha=0.75)
# Add a cumulative density function (CDF) line
plt.hist(data, bins=20, alpha=0.5, cumulative=True,
histtype='step', color='red', range=(-3, 3),
density=True)
# Add a rug plot showing individual data points
plt.plot(data, np.zeros_like(data), '|', color='black')
# Show the plot
plt.show()