Python ❤️ ECharts = pyecharts - comprehensive data visualization toolkit built on Apache ECharts
npx @tessl/cli install tessl/pypi-pyecharts@2.0.0A comprehensive Python library for creating interactive charts and data visualizations built on top of Apache ECharts. pyecharts provides a fluent, chainable API supporting 30+ chart types with extensive customization options and seamless integration with popular development environments.
pip install pyechartsimport pyecharts
from pyecharts import options as opts
from pyecharts.charts import Bar, Line, Pie # Import specific chart typesCommon usage pattern:
from pyecharts.charts import Bar
from pyecharts import options as optsfrom pyecharts.charts import Bar
from pyecharts import options as opts
# Create a bar chart with fluent API
bar = (
Bar()
.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
.add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
.add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
.set_global_opts(title_opts=opts.TitleOpts(title="某商场销售情况"))
)
# Render to HTML file
bar.render("bar_chart.html")
# For Jupyter notebooks
bar.render_notebook()pyecharts follows a layered architecture designed for flexibility and extensibility:
The fluent API design enables method chaining for intuitive chart construction, while the separation of chart logic from styling options provides maximum flexibility for customization.
Core 2D chart types including bar charts, line charts, scatter plots, pie charts, maps, and specialized visualizations. These form the foundation of pyecharts' visualization capabilities.
class Bar:
def __init__(self, init_opts=None, render_opts=None): ...
def add_xaxis(self, xaxis_data): ...
def add_yaxis(self, series_name, y_axis, **kwargs): ...
def reversal_axis(self): ...
class Line:
def __init__(self, init_opts=None, render_opts=None): ...
def add_xaxis(self, xaxis_data): ...
def add_yaxis(self, series_name, y_axis, **kwargs): ...
class Pie:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data_pair, **kwargs): ...Map-based visualizations including choropleth maps, geographic scatter plots, and integration with multiple mapping providers (Baidu, Google, Alibaba, Leaflet).
class Map:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data_pair, maptype="china", **kwargs): ...
class Geo:
def __init__(self, init_opts=None, render_opts=None): ...
def add_coordinate(self, name, longitude, latitude): ...
def add(self, series_name, data_pair, **kwargs): ...
class BMap:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data_pair, **kwargs): ...Three-dimensional visualizations including 3D bar charts, scatter plots, surface plots, and globe representations with advanced lighting and material effects.
class Bar3D:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data, **kwargs): ...
class Scatter3D:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data, **kwargs): ...
class Surface3D:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, series_name, data, **kwargs): ...Multi-chart layouts and complex visualizations including grids, timelines, tabs, and multi-page documents for creating dashboards and comprehensive reports.
class Grid:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, chart, grid_opts, grid_index=0): ...
class Timeline:
def __init__(self, init_opts=None, render_opts=None): ...
def add(self, chart, time_point): ...
class Page:
def __init__(self, page_title="Awesome-pyecharts", layout_opts=None): ...
def add(self, *charts): ...Comprehensive styling and behavior configuration system with global options for chart-wide settings and series options for individual data series customization.
class TitleOpts:
def __init__(self, title=None, subtitle=None, pos_left=None, pos_top=None, **kwargs): ...
class LegendOpts:
def __init__(self, type_=None, is_show=True, pos_left=None, pos_top=None, **kwargs): ...
class TooltipOpts:
def __init__(self, is_show=True, trigger="item", formatter=None, **kwargs): ...
class AxisOpts:
def __init__(self, type_=None, name=None, min_=None, max_=None, **kwargs): ...Chart rendering capabilities supporting multiple output formats including HTML files, static images, Jupyter notebook integration, and web framework compatibility.
def make_snapshot(driver, file_content, output_name, delay=1, pixel_ratio=1, is_remove_html=False, **kwargs): ...
class Base:
def render(self, path="render.html"): ...
def render_embed(self): ...
def render_notebook(self): ...Helper utilities for JavaScript code injection, geographic data management, and custom chart extensions.
class JsCode:
def __init__(self, js_code): ...
def replace(self, pattern, repl): ...
def register_url(asset_url): ...
def register_files(asset_files): ...
def register_coords(coords): ...