histogram

PHOTO EMBED

Fri Oct 06 2023 13:04:41 GMT+0000 (Coordinated Universal Time)

Saved by @stacyjacqueen #python

import numpy as np
import matplotlib.pyplot as plt

# Create a sample dataset
data = np.random.randn(1000)

# Calculate the number of bins
num_bins = 10

# Create a histogram
hist, bins = np.histogram(data, bins=num_bins)

# Plot the histogram
plt.bar(bins[:-1], hist, width=bins[1] - bins[0])
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.title("Histogram of Sample Data")
plt.show()
content_copyCOPY