Geospatial
Interactive

Choropleth Map

Choropleth maps use color gradients to represent statistical values across defined geographic regions such as countries, states, or counties. Each region is shaded according to its data value, creating a powerful visualization for comparing metrics across geography. These maps are widely used in demographics, election results, epidemiology, and economic analysis. When creating choropleths, consider using appropriate color scales and potentially logarithmic transformations for skewed data.

Interactive Visualization

Loading interactive chart...

This is an interactive choropleth map. You can zoom, pan, and hover over elements for details.

Try this prompt

"Use Plotly to create an interactive choropleth map of the world showing 'GDP per Capita'. Use a logarithmic color scale. Generate a proper example dataset to demonstrate this visualization."
Generate this now

Python Code Example

example.py
import plotly.express as px
import pandas as pd
import numpy as np

# Generate sample GDP per capita data for demonstration
countries = [
    'United States', 'China', 'Japan', 'Germany', 'United Kingdom', 
    'France', 'India', 'Italy', 'Brazil', 'Canada', 'Russia', 
    'South Korea', 'Spain', 'Australia', 'Mexico'
]

# Assign realistic GDP per capita values
np.random.seed(42)
gdp_values = np.random.uniform(2000, 70000, size=len(countries))

df = pd.DataFrame({'Country': countries, 'GDP_per_Capita': gdp_values})

# Create choropleth map
fig = px.choropleth(
    df,
    locations='Country',
    locationmode='country names',
    color='GDP_per_Capita',
    color_continuous_scale='Viridis',
    title='World GDP per Capita',
    labels={'GDP_per_Capita': 'GDP per Capita (USD)'},
    projection='natural earth'
)

fig.update_layout(geo=dict(showframe=False, showcoastlines=True))
fig.show()

Common Use Cases

  • 1Visualizing population density by region
  • 2Election results by state or county
  • 3COVID-19 case rates by country
  • 4Economic indicators across nations

Pro Tips

Use diverging color scales for data with meaningful midpoint

Consider logarithmic scales for highly skewed data

Add hover information for exact values