Skip to content

Instantly share code, notes, and snippets.

@msdousti
Created April 6, 2025 12:37
Show Gist options
  • Save msdousti/f94ebbb9f69204f4de1ba64391b0f6c5 to your computer and use it in GitHub Desktop.
Save msdousti/f94ebbb9f69204f4de1ba64391b0f6c5 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
# Provided data
data = [
5, 18, 32, 40, 54, 68, 80, 100, 110, 119, 125, 136, 144, 149, 154, 160, 165,
171, 178, 182, 189, 195, 202, 211, 216, 222, 227, 234, 239, 245, 250, 256,
261, 268, 273, 278, 283, 289, 295, 301, 307, 314, 320, 325, 332, 339, 346,
352, 358, 364, 370, 376, 383, 389, 396, 402, 409, 415, 422, 429, 436, 443,
450, 458, 466, 473, 481, 489, 496, 503, 511, 519, 527, 536, 545, 555, 564,
573, 583, 593, 603, 613, 623, 633, 645, 657, 668, 680, 693, 706, 721, 734,
749, 765, 783, 802, 824, 846, 873, 910, 994
]
# Define histogram bins
bins = list(range(0, 1001, 100))
# Create histogram
plt.figure(figsize=(10, 6))
plt.hist(data, bins=bins, edgecolor='black')
plt.title('Histogram of Data (Buckets of 100)')
plt.xlabel('Value Range')
plt.ylabel('Frequency')
plt.xticks(bins)
plt.grid(axis='y')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment