This project implements a comprehensive data visualization system for Turkey's census data from 1927 to 2023 using Plotly interactive charts and geographic mapping. The system analyzes demographic trends across Turkey's 81 provinces, providing insights into population distribution, gender ratios, and historical changes over nearly a century.
The project addresses the need for interactive demographic analysis and visualization in applications such as urban planning, resource allocation, policy development, and academic research. By leveraging modern visualization libraries (Plotly, Folium) and geographic data, the system offers dynamic, web-friendly visualizations that enable detailed examination of population patterns.
The implementation demonstrates practical applications of data science for demographic analysis, processing census data from TUIK (Turkish Statistical Institute) to create interactive line charts, bar graphs, pie charts, and choropleth maps that reveal population trends and regional variations.
Core Features:
The system employs Python data analysis libraries (Pandas, NumPy) for data processing and Plotly for interactive visualization. Geographic visualizations use GeoPandas and Folium to create choropleth maps showing population density across Turkish provinces.
The population visualization pipeline consists of:
The implementation uses Jupyter Notebooks for interactive analysis with two main components: historical analysis (1927-2023) and current snapshot (2023). Data processing includes alphabetical to plate code sorting, gender ratio calculations, and geographic coordinate matching. Plotly provides interactive charts with hover tooltips, while Folium creates interactive maps with province boundaries and population markers.
The analysis employs several mathematical calculations and statistical methods to process and visualize demographic data:
Male Population Ratio:
$$\text{Male_Ratio} = \frac{\text{Male_Population}}{\text{Total_Population}} \times 100$$
Female Population Ratio:
$$\text{Female_Ratio} = \frac{\text{Female_Population}}{\text{Total_Population}} \times 100$$
Gender Difference:
$$\text{Gender_Difference} = |\text{Male_Population} - \text{Female_Population}|$$
Annual Growth Rate:
$$\text{Growth_Rate} = \frac{\text{Population_Year}_n - \text{Population_Year}_{n-1}}{\text{Population_Year}_{n-1}} \times 100$$
Compound Annual Growth Rate (CAGR):
$$\text{CAGR} = \left[\left(\frac{\text{Population_Final}}{\text{Population_Initial}}\right)^{\frac{1}{\text{Years}}} - 1\right] \times 100$$
Average Provincial Population:
$$\text{Avg_Population} = \frac{\sum \text{Province_Populations}}{\text{Number_of_Provinces}}$$
Population Density (when area data available):
$$\text{Density} = \frac{\text{Total_Population}}{\text{Area_km}^2}$$
Choropleth Color Scaling:
$$\text{Normalized_Value} = \frac{\text{Value} - \text{Min_Value}}{\text{Max_Value} - \text{Min_Value}}$$
Coordinate Transformations:
For comparative visualizations, population data is normalized using:
$$\text{Normalized_Population} = \frac{\text{Population} - \text{Mean}}{\text{Standard_Deviation}}$$
These mathematical frameworks enable accurate demographic analysis, trend identification, and visual representation of population patterns across Turkey's provinces over the 96-year period.
requirements.txt
numpy>=1.19.0
pandas>=1.3.0
plotly>=5.0.0
geopandas>=0.10.0
folium>=0.12.0
This section provides detailed information about the datasets used in the project.
Description: Comprehensive census data for all Turkish provinces from 1927 to 2023.
Structure:
Columns:
| Column Name | Turkish Name | Data Type | Description |
|---|---|---|---|
| Year | Yıl | Integer | Census year (1927-2023) |
| Province | İl | String | Province name |
| Total | Toplam | Integer | Total population |
| Male | Erkek | Integer | Male population |
| Female | Kadın | Integer | Female population |
Data Source: TUIK (Türkiye İstatistik Kurumu - Turkish Statistical Institute)
Sample Data:
Yıl,İl,Toplam,Erkek,Kadın
2023,İstanbul,15655924,7806787,7849137
2023,Ankara,5803482,2860361,2943121
2023,İzmir,4479525,2221180,2258345
Description: Geographic boundary data for Turkish provinces in GeoJSON format.
Structure:
Properties:
Usage: Used for creating choropleth maps and geographic visualizations with Folium.
Coordinate Reference:
Census Years:
Data Integrity:
Known Considerations:
# Clone the repository
git clone https://github.com/kemalkilicaslan/Data-Visualization-of-Turkey-Population-with-Plotly.git
cd Data-Visualization-of-Turkey-Population-with-Plotly
# Install required packages
pip install -r requirements.txt
Data-Visualization-of-Turkey-Population-with-Plotly
├── Data-Visualisation-of-Turkey-Population-with-Plotly-1927-2023.ipynb
├── Data-Visualisation-of-Turkey-Population-with-Plotly-2023.ipynb
├── TR-population.csv # Census data (1927-2023)
├── TR_map.json # Geographic boundary data
├── README.md
├── requirements.txt
└── LICENSE
Historical Analysis (1927-2023):
jupyter notebook Data-Visualisation-of-Turkey-Population-with-Plotly-1927-2023.ipynb
Current Snapshot (2023):
jupyter notebook Data-Visualisation-of-Turkey-Population-with-Plotly-2023.ipynb
Load Census Data:
import pandas as pd
data = pd.read_csv('TR-population.csv')
Filter by Year:
data_2023 = data[data['Yıl'] == 2023]
Calculate Gender Ratios:
data_2023['Erkek_oran'] = data_2023['Erkek'] / data_2023['Toplam']
data_2023['Kadın_oran'] = data_2023['Kadın'] / data_2023['Toplam']
Create Interactive Chart:
import plotly.express as px
fig = px.line(data, x='Yıl', y='Toplam',
title='Turkey Total Population (1927-2023)')
fig.show()
Generate Choropleth Map:
import folium
turkey_map = folium.Map(location=[38.96, 35.36], zoom_start=6)
folium.Choropleth(
geo_data='TR_map.json',
data=data_2023,
columns=['İl', 'Toplam'],
key_on='feature.properties.name',
fill_color='Greys'
).add_to(turkey_map)
turkey_map
Total Population Change:
Male and Female Population Trends:
Istanbul Demographics:
Key Years - Gender Distribution:
1990: Largest male-female gap (288,332 difference)
2022: Smallest male-female gap (3,689 difference)
2023: First year female population exceeded male (42,350 difference)
Ankara Demographics:
Key Years - Gender Distribution:
1975: Largest male-female gap (133,453 difference)
1927: Smallest male-female gap (6,016 difference)
2007: First year female population exceeded male (16,690 difference)
2023: Largest female population advantage (82,760 difference)
Izmir Demographics:
Key Years - Gender Distribution:
1985: Largest male-female gap (78,643 difference)
2008: First year female exceeded male, smallest gap (394 difference)
2023: Largest female population advantage (37,165 difference)
Combined Population Trends:
Male Population Comparison:
Female Population Comparison:
Historical Snapshots:
City Pair Comparisons:
All Provinces - Combined:
Individual Categories:
Gender Ratio Analysis:
Highest male ratio: Hakkari (53.62%)
Highest female ratio: Ankara (50.71%)
Population Rankings:
Most populous: Istanbul (15.66M), Ankara (5.80M), Izmir (4.48M)
Least populous: Bayburt (86K), Tunceli (89K), Ardahan (93K)
Total Population Map:
Male Population Map:
Female Population Map:
National Statistics (2023):
| Metric | Value |
|---|---|
| Total Population | 85,372,377 |
| Male Population | 42,718,072 (50.03%) |
| Female Population | 42,654,305 (49.97%) |
| Number of Provinces | 81 |
| Average Province Population | 1,053,980 |
Major Cities Population (2023):
| City | Total | Male | Female | Female Advantage |
|---|---|---|---|---|
| Istanbul | 15,655,924 | 7,806,787 | 7,849,137 | +42,350 |
| Ankara | 5,803,482 | 2,860,361 | 2,943,121 | +82,760 |
| Izmir | 4,479,525 | 2,221,180 | 2,258,345 | +37,165 |
[Census Data CSV (TUIK)]
↓
[Pandas Data Loading]
├── Read TR-population.csv
└── Load geographic data (TR_map.json)
↓
[Data Processing]
├── Filter by year/province
├── Calculate gender ratios
├── Sort and aggregate
└── Match province coordinates
↓
[Statistical Analysis]
├── Historical trends (1927-2023)
├── Gender distribution
├── Provincial comparisons
└── Population rankings
↓
[Visualization Generation]
├── Plotly Interactive Charts
│ ├── Line charts (trends)
│ ├── Bar charts (comparisons)
│ ├── Pie/Donut charts (distributions)
│ └── Stacked/Grouped bars (ratios)
└── Folium Geographic Maps
├── Choropleth (density)
├── Markers (province labels)
└── Tooltips (hover data)
↓
[Interactive Output]
├── Web-ready HTML
├── Zoom/Pan controls
├── Hover tooltips
└── Export capabilities
| Library | Version | Purpose |
|---|---|---|
| pandas | 1.3+ | Data manipulation and analysis |
| numpy | 1.19+ | Numerical operations |
| plotly | 5.0+ | Interactive charts and graphs |
| geopandas | 0.10+ | Geographic data processing |
| folium | 0.12+ | Interactive map generation |
Plotly Charts:
Folium Maps:
Input Data:
Output Formats:
This project is open source and available under the Apache License 2.0.
This project uses population census data from TUIK (Türkiye İstatistik Kurumu - Turkish Statistical Institute). Special thanks to the open-source communities behind Plotly, Folium, and GeoPandas for providing excellent data visualization tools. Geographic boundary data is used for educational and research purposes.
Note: This project is designed for educational, research, and data analysis purposes. The visualizations and analyses are based on official TUIK census data. When using demographic data for policy or planning purposes, please refer to the official TUIK publications and consider consulting with demographic experts. Population figures are subject to annual updates and revisions by TUIK.