Complete reference for country visualization and geographic analysis functions
Create a professional 2D choropleth world map for country data visualization. This is the primary function for creating flat world maps with country-level data.
country_choropleth_map(
data,
country_col='country',
value_col='value',
title='Country Risk Distribution',
backend='plotly',
color_scale='RdYlGn_r',
**kwargs
)
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
pd.DataFrame | Required | DataFrame containing country and value data |
country_col |
str | 'country' | Column name containing country codes or names |
value_col |
str | 'value' | Column name containing values to visualize |
title |
str | 'Country Risk Distribution' | Map title |
backend |
str | 'plotly' | Visualization backend: 'plotly' or 'matplotlib' |
color_scale |
str | 'RdYlGn_r' | Color scale for the visualization |
fig : plotly.graph_objects.Figure or matplotlib.figure.Figure
Interactive or static figure object ready for display or export
import riskplot
import pandas as pd
# Create sample data
data = pd.DataFrame({
'country': ['USA', 'Germany', 'China', 'Japan'],
'risk_score': [0.25, 0.18, 0.45, 0.22]
})
# Create map
fig = riskplot.country_choropleth_map(
data,
country_col='country',
value_col='risk_score',
title='Global Risk Assessment',
width=1200,
height=700
)
fig.show()
Create an interactive 3D globe visualization for country risk data. Provides engaging 3D perspective perfect for presentations.
country_risk_globe(
data,
country='country',
risk='risk_score',
title='Global Country Risk Distribution',
**kwargs
)
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
pd.DataFrame | Required | DataFrame containing country and risk data |
country |
str | 'country' | Column name for country codes (ISO-3 recommended) |
risk |
str | 'risk_score' | Column name for risk values |
title |
str | 'Global Country Risk Distribution' | Globe title |
center_lon |
float | 0 | Center longitude for globe rotation |
center_lat |
float | 0 | Center latitude for globe rotation |
# Create 3D globe
fig = riskplot.country_risk_globe(
data,
country='ISO_Code',
risk='risk_score',
title='Global Risk Assessment - 3D View',
center_lon=0,
center_lat=30
)
fig.show()
Create a heatmap showing countries grouped by regions for comparative analysis.
regional_risk_heatmap(
data,
region_col='region',
country_col='country',
value_col='value',
title='Regional Risk Heatmap',
figsize=(12, 8)
)
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
pd.DataFrame | Required | DataFrame with region, country, and value data |
region_col |
str | 'region' | Column name for regions |
country_col |
str | 'country' | Column name for countries |
value_col |
str | 'value' | Column name for values |
title |
str | 'Regional Risk Heatmap' | Plot title |
figsize |
tuple | (12, 8) | Figure size in inches |
Advanced class for creating customizable 2D world map visualizations with multiple backend support.
WorldMapPlot(backend='plotly')
Create a professional 2D choropleth world map.
plot_choropleth(
data,
country_col='country',
value_col='value',
title='Country Risk Map',
color_scale='RdYlGn_r',
show_borders=True,
ocean_color='lightblue',
missing_color='lightgray',
**kwargs
)
Add markers and annotations to the map.
add_annotations(
annotations_data,
lat_col='latitude',
lon_col='longitude',
text_col='text',
marker_size=8,
marker_color='red'
)
Save the map to file in various formats.
save(filename, **kwargs)
Display the interactive map.
show()
# Advanced customization
world_map = riskplot.WorldMapPlot(backend='plotly')
# Create custom map
fig = world_map.plot_choropleth(
data,
country_col='country',
value_col='risk_score',
title='Advanced Risk Assessment',
color_scale='Viridis',
show_borders=True,
ocean_color='lightsteelblue',
width=1200,
height=800
)
# Add city markers
cities = pd.DataFrame({
'latitude': [40.7, 51.5, 35.7],
'longitude': [-74.0, -0.1, 139.7],
'text': ['New York', 'London', 'Tokyo']
})
world_map.add_annotations(cities, marker_color='red', marker_size=10)
# Save in multiple formats
world_map.save('risk_map.html')
world_map.save('risk_map.png')
world_map.show()
Advanced class for creating interactive 3D globe visualizations with connection mapping capabilities.
GlobeRiskPlot()
Create basic globe visualization.
plot(
data,
country='country',
value='value',
title='Global Risk Distribution',
color_scale='RdYlGn_r',
**kwargs
)
Create globe with connection lines between countries.
plot_connections(
data,
src_country='source_country',
tgt_country='target_country',
strength='strength',
src_lat='source_lat',
src_lon='source_lon',
tgt_lat='target_lat',
tgt_lon='target_lon',
title='Global Risk Connections',
**kwargs
)
Create animated globe showing data evolution over time.
plot_time_series(
data,
country_col='country',
value_col='value',
time_col='date',
title='Global Risk Over Time',
**kwargs
)
Recommended color scales for different types of risk data:
Use for: Risk scores, default for most risk visualizations
Scale: Red (high risk) → Yellow (medium) → Green (low risk)
Use for: Performance scores, ESG ratings
Scale: Green (good) → Yellow (medium) → Red (poor)
Use for: General data visualization, colorblind-friendly
Scale: Purple → Blue → Green → Yellow
Use for: Economic indicators, growth rates
Scale: Light blue → Dark blue
RiskPlot automatically handles multiple country code formats:
USA, GBR, DEU, CHN, JPN, FRA, etc.
US, GB, DE, CN, JP, FR, etc.
United States, United Kingdom, Germany, China, etc.
UK → United Kingdom, USA → United States