Python ❤️ ECharts = pyecharts - comprehensive data visualization toolkit built on Apache ECharts
—
Map-based visualizations for geographic and spatial data analysis. pyecharts provides comprehensive mapping capabilities with support for multiple map providers, custom geographic coordinates, and over 400 built-in map files for countries, provinces, and cities.
Geographic maps with regions colored by data values, ideal for visualizing regional statistics and geographic distributions.
class Map:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize a choropleth map.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add(self, series_name, data_pair, maptype="china", **kwargs):
"""
Add choropleth map data.
Args:
series_name (str): Name of the data series
data_pair (list): List of [region_name, value] pairs or MapItem objects
maptype (str): Map type identifier ("china", "world", province names, etc.)
is_roam (bool, optional): Enable pan and zoom
zoom (float, optional): Initial zoom level
center (list, optional): Map center coordinates [longitude, latitude]
is_map_symbol_show (bool, optional): Show map symbols
Returns:
Map: Self for method chaining
"""Usage Example:
from pyecharts.charts import Map
from pyecharts import options as opts
data = [
("北京", 199),
("上海", 188),
("广东", 150),
("江苏", 139),
("浙江", 134)
]
map_chart = (
Map()
.add("销售额", data, "china")
.set_global_opts(
title_opts=opts.TitleOpts(title="中国各省份销售额"),
visualmap_opts=opts.VisualMapOpts(max_=200)
)
)Scatter plots and other visualizations on geographic coordinate systems.
class Geo:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize a geographic coordinate chart.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add_coordinate(self, name, longitude, latitude):
"""
Add custom geographic coordinates.
Args:
name (str): Location name
longitude (float): Longitude coordinate
latitude (float): Latitude coordinate
Returns:
Geo: Self for method chaining
"""
def add(self, series_name, data_pair, **kwargs):
"""
Add geographic data series.
Args:
series_name (str): Name of the data series
data_pair (list): List of [location_name, value] pairs or GeoItem objects
type_ (str): Chart type ("scatter", "effectScatter", "heatmap", "lines")
symbol (str, optional): Symbol type for scatter plots
symbol_size (int|list, optional): Symbol size
is_roam (bool, optional): Enable pan and zoom
maptype (str, optional): Map type identifier
Returns:
Geo: Self for method chaining
"""Integration with Baidu Maps for web-based interactive mapping with street-level detail.
class BMap:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize a Baidu map chart.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add(self, series_name, data_pair, **kwargs):
"""
Add data to Baidu map.
Args:
series_name (str): Name of the data series
data_pair (list): List of [location_name, value] pairs
type_ (str): Chart type ("scatter", "effectScatter", "heatmap", "lines")
is_roam (bool, optional): Enable map interaction
map_style (dict, optional): Baidu map styling options
Returns:
BMap: Self for method chaining
"""
def add_schema(self, **kwargs):
"""
Configure Baidu map settings.
Args:
baidu_ak (str): Baidu API key
center (list): Map center coordinates [longitude, latitude]
zoom (int): Initial zoom level
is_roam (bool): Enable pan and zoom
map_style (dict): Map styling configuration
Returns:
BMap: Self for method chaining
"""Integration with Google Maps for global mapping capabilities.
class GMap:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize a Google map chart.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add(self, series_name, data_pair, **kwargs):
"""
Add data to Google map.
Args:
series_name (str): Name of the data series
data_pair (list): List of [location_name, value] pairs
type_ (str): Chart type ("scatter", "effectScatter", "heatmap", "lines")
is_roam (bool, optional): Enable map interaction
Returns:
GMap: Self for method chaining
"""
def add_schema(self, **kwargs):
"""
Configure Google map settings.
Args:
google_api_key (str): Google Maps API key
center (list): Map center coordinates [longitude, latitude]
zoom (int): Initial zoom level
map_type (str): Map type ("roadmap", "satellite", "hybrid", "terrain")
Returns:
GMap: Self for method chaining
"""Integration with Alibaba's AMap (Gaode Maps) service.
class AMap:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize an Alibaba map chart.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add(self, series_name, data_pair, **kwargs):
"""
Add data to Alibaba map.
Args:
series_name (str): Name of the data series
data_pair (list): List of [location_name, value] pairs
type_ (str): Chart type ("scatter", "effectScatter", "heatmap", "lines")
Returns:
AMap: Self for method chaining
"""Integration with Leaflet for customizable web mapping.
class LMap:
def __init__(self, init_opts=None, render_opts=None):
"""
Initialize a Leaflet map chart.
Args:
init_opts (InitOpts, optional): Chart initialization options
render_opts (RenderOpts, optional): Rendering options
"""
def add(self, series_name, data_pair, **kwargs):
"""
Add data to Leaflet map.
Args:
series_name (str): Name of the data series
data_pair (list): List of [location_name, value] pairs
type_ (str): Chart type ("scatter", "effectScatter", "heatmap", "lines")
Returns:
LMap: Self for method chaining
"""class MapItem:
def __init__(self, name=None, value=None, **kwargs):
"""
Map data item for choropleth maps.
Args:
name (str): Region name
value (numeric): Data value
**kwargs: Additional styling options
"""
class GeoItem:
def __init__(self, name=None, value=None, **kwargs):
"""
Geographic coordinate data item.
Args:
name (str): Location name
value (numeric): Data value
**kwargs: Additional styling options
"""class GeoRegionsOpts:
def __init__(self, **kwargs):
"""
Geographic region styling options.
Args:
name (str): Region name
itemstyle_opts (ItemStyleOpts): Region styling
label_opts (LabelOpts): Region label options
emphasis_opts (EmphasisOpts): Hover/focus styling
"""
class BMapCopyrightTypeOpts:
def __init__(self, **kwargs):
"""Baidu map copyright configuration."""
class BMapGeoLocationControlOpts:
def __init__(self, **kwargs):
"""Baidu map geolocation control options."""
class BMapNavigationControlOpts:
def __init__(self, **kwargs):
"""Baidu map navigation control options."""
class BMapOverviewMapControlOpts:
def __init__(self, **kwargs):
"""Baidu map overview control options."""
class BMapScaleControlOpts:
def __init__(self, **kwargs):
"""Baidu map scale control options."""
class BMapTypeControlOpts:
def __init__(self, **kwargs):
"""Baidu map type selection control options."""pyecharts includes comprehensive geographic data support:
# Geographic data dictionaries (from pyecharts.datasets)
FILENAMES # FuzzyDict containing map filename mappings
COORDINATES # FuzzyDict containing city coordinate mappings
# Registration functions for custom geographic data
def register_url(asset_url):
"""
Register external map asset URLs.
Args:
asset_url (str): Base URL for map assets
"""
def register_files(asset_files):
"""
Register custom map files.
Args:
asset_files (dict): Mapping of region names to filenames
"""
def register_coords(coords):
"""
Register custom coordinates.
Args:
coords (dict): Mapping of location names to [longitude, latitude] pairs
"""Usage Example:
from pyecharts.datasets import register_coords
# Add custom coordinates
custom_coords = {
"Custom Location": [116.46, 39.92],
"Another Place": [121.48, 31.22]
}
register_coords(custom_coords)pyecharts includes over 400 built-in map files:
Common map type identifiers:
"china" - China national map"world" - World map"北京" - Beijing city map"广东" - Guangdong province map"USA" - United States map"UK" - United Kingdom mapInstall with Tessl CLI
npx tessl i tessl/pypi-pyecharts