File size: 2,357 Bytes
dc19bc3
 
 
 
 
 
 
 
 
 
28870a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32c945b
28870a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32c945b
28870a0
 
 
 
 
 
32c945b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28870a0
 
 
73d3b4c
 
 
 
 
 
28870a0
73d3b4c
 
 
 
 
 
28870a0
73d3b4c
 
 
 
 
 
 
28870a0
73d3b4c
28870a0
73d3b4c
28870a0
73d3b4c
dc19bc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
datasets:
- hj
language:
- en
license: bsd
tags:
- crime
- homicide
---
# 2025 Homicide Trend Analysis

![License](https://img.shields.io/badge/license-BSD--3--Clause--Clear-blue )
![Python](https://img.shields.io/badge/python-3.8+-blue.svg )
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-lightgrey )

πŸ“Š This project provides Python-based data visualization examples for analyzing homicide trends over time.

Source: [HeyJackass.com](https://heyjackass.com )

---

## πŸ“Š Overview

This repository includes Python scripts to visualize homicide data using:
- Bar graphs
- Pie charts
- DataFrames from `pandas`

All visualizations are based on real-world data spanning from **2015 to 2024**.

---

## πŸ“ˆ Sample Data

| Year | Homicides |
|------|-----------|
| 2024 | 219       |
| 2023 | 257       |
| 2022 | 261       |
| 2021 | 276       |
| 2020 | 254       |
| 2019 | 211       |
| 2018 | 211       |
| 2017 | 257       |
| 2016 | 262       |
| 2015 | 174       |

---

## πŸ“Š Visualization Examples

### 1. Bar Graph: Homicides Per Year

```python
import matplotlib.pyplot as plt
import pandas as pd

# Data from your CSV
data = {
    'Year': [2024, 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015],
    'Homicides': [219, 257, 261, 276, 254, 211, 211, 257, 262, 174]
}

# Convert to DataFrame
df = pd.DataFrame(data)

# Plot bar graph
plt.figure(figsize=(10, 6))
plt.bar(df['Year'].astype(str), df['Homicides'], color='skyblue')
plt.title('Homicides Per Year')
plt.xlabel('Year')
plt.ylabel('Number of Homicides')
plt.xticks(rotation=45)
plt.tight_layout()

# Show the plot
plt.show()
```
### 2. Pie Chart: Distribution of Incidents by Year
```python
from datasets import load_dataset
import matplotlib.pyplot as plt

# Load the dataset
ds = load_dataset("ajsbsd/hj")

# Count year occurrences
year_counts = {}
for entry in ds['train']:
    year = entry.get('Year', None)
    if year is not None:
        year_counts[year] = year_counts.get(year, 0) + 1

# Sort years
sorted_years = sorted(year_counts.items())
years, counts = zip(*sorted_years)

# Plot pie chart
plt.figure(figsize=(8, 8))
plt.pie(counts, labels=years, autopct='%1.1f%%', startangle=140)
plt.title('Distribution of Incidents by Year')
plt.axis('equal')
plt.show()
```

BSD-3-Clause-Clear License

See LICENSE file for full text.