Python pyecharts Module
pyecharts is a Python data visualization library based on Apache ECharts. It lets you quickly generate interactive charts such as bar, line, pie, scatter, and map charts with Python code.
ECharts is an open-source JavaScript data visualization library offering a rich set of chart types and interactions. pyecharts wraps ECharts in Python, so developers can create feature-rich visualizations without writing complex JavaScript directly.
pyecharts provides a simple, flexible API that supports customizing chart titles, axes, legends, tooltips, themes, animations and more.
With pyecharts you can process data in Python first and then turn it into an interactive chart. The generated chart is usually saved as an HTML file, which can be viewed in a browser or embedded in a web application or a Jupyter Notebook.
Features and capabilities of pyecharts:
-
Easy to use: Provides an intuitive Python API that creates charts with only a few lines of code, making it ideal for beginners.
-
A rich variety of chart types: Supports line charts, bar charts, scatter plots, pie charts, radar charts, maps, word clouds, 3D charts and more.
-
Convenient data handling: Chart data can be organized with Python data structures such as lists and dictionaries, or handled together with Pandas DataFrames.
-
Highly interactive: Supports hover tooltips, legend toggling, data zoom, toolbox and other interactions, depending on the chart type and configuration.
-
A wide range of configuration options: Titles, axes, legends, tooltips, labels, colors and chart sizes can all be customized.
-
Multiple built-in themes: Built-in themes let you quickly change the chart's color scheme and overall visual style.
-
Supports multiple runtime environments: Can generate HTML files and also works in Jupyter Notebook, Flask, Django and other environments.
Installing pyecharts
pyecharts can be installed with pip; Python 3 is recommended.
Install with pip:
pip install pyecharts
You can also use the following command to install or upgrade to the latest version:
python -m pip install --upgrade pyecharts
If your system uses the python3 command, you can run:
python3 -m pip install --upgrade pyecharts
Install from source:
git clone https://github.com/pyecharts/pyecharts.git
cd pyecharts
python -m pip install .
The source installation above uses pip to install the project in the current directory; you normally do not need to run python setup.py install。
After installation, you can check the pyecharts version with the following command:
python -c "import pyecharts; print(pyecharts.__version__)"
You can also check the version from Python code:
import pyecharts
print(pyecharts.__version__)
The output looks like this (using pyecharts 2.1.0 as an example):
2.1.0
pyecharts 2.1.0 was released in February 2026 and added support for ECharts 6.x. The actual version number shown depends on the version installed.
Note: pyecharts mainly generates the HTML and JavaScript configuration required by a chart; the browser needs to load the relevant JavaScript resources to display it. If the HTML file opens but the chart is blank, check the browser console and whether those resources loaded successfully.
pyecharts chart types
pyecharts supports many chart types. Here are some commonly used charts and their corresponding Python classes:
| Chart type | pyecharts class | Import |
|---|---|---|
| Line chart | Line |
from pyecharts.charts import Line |
| Bar chart | Bar |
from pyecharts.charts import Bar |
| Scatter chart | Scatter |
from pyecharts.charts import Scatter |
| Pie chart | Pie |
from pyecharts.charts import Pie |
| Radar chart | Radar |
from pyecharts.charts import Radar |
| Heatmap | HeatMap |
from pyecharts.charts import HeatMap |
| Candlestick chart | Kline |
from pyecharts.charts import Kline |
| Boxplot | Boxplot |
from pyecharts.charts import Boxplot |
| Map | Map |
from pyecharts.charts import Map |
| Word cloud | WordCloud |
from pyecharts.charts import WordCloud |
| Gauge | Gauge |
from pyecharts.charts import Gauge |
| Funnel chart | Funnel |
from pyecharts.charts import Funnel |
| Tree chart | Tree |
from pyecharts.charts import Tree |
| Treemap | TreeMap |
from pyecharts.charts import TreeMap |
| Graph (relationship) chart | Graph |
from pyecharts.charts import Graph |
| Parallel coordinates chart | Parallel |
from pyecharts.charts import Parallel |
| Sankey diagram | Sankey |
from pyecharts.charts import Sankey |
| Geographic coordinate system chart | Geo |
from pyecharts.charts import Geo |
| Timeline component | Timeline |
from pyecharts.charts import Timeline |
| 3D scatter chart | Scatter3D |
from pyecharts.charts import Scatter3D |
| 3D bar chart | Bar3D |
from pyecharts.charts import Bar3D |
| 3D surface chart | Surface3D |
from pyecharts.charts import Surface3D |
| Chord diagram (2.1.0+) | Chord |
from pyecharts.charts import Chord |
Explanation: Timeline It is mainly used to organize and switch between multiple charts in chronological order, and is not an independent data chart type. Maps, geographic coordinate charts and some 3D charts may require additional JavaScript or map data resources.
Create the first chart
Next we use pyecharts to create a simple bar chart showing the sales of a product over five months.
Example
from
pyecharts.
charts
import
Bar
Prepare data
x_data
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
]
y_data
=
[
10
,
20
,
15
,
25
,
30
]
Create the bar chart
bar_chart
=
Bar
(
)
Add the x-axis data
bar_chart.
add_xaxis
(
x_data
)
Add the data series
bar_chart.
add_yaxis
(
"Sales"
,
y_data
)
Generate the HTML file
bar_chart.
render
(
)
The code above first uses Bar() to create a bar chart object, then add_xaxis() to add the month data, and add_yaxis() to add the sales figures, and finally calls render() to generate the chart.
If the file has been modified after the time specified in bar_chart.render() If no file path is specified in , pyecharts generates a file named render.html in the current working directory by default.
Running the code above produces:

If you want to specify a chart file name or save path, you can render() pass a file path argument to the method, for example:
bar_chart.render("my_bar_chart.html")
The resulting chart will then be saved in the current working directory as my_bar_chart.html file.
Note: render() By default an interactive HTML file is generated, not a static image such as PNG or JPG. To export an image you usually need a screenshot tool or another image export solution.
Set chart configuration options
The bar chart above displays the data correctly but lacks a title and axis descriptions. We can use pyecharts configuration items to add a title, an x-axis name and a y-axis name.
Example
from
pyecharts
import
options
as
opts
from
pyecharts.
charts
import
Bar
Prepare data
x_data
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
]
y_data
=
[
10
,
20
,
15
,
25
,
30
]
Create the bar chart
bar_chart
=
Bar
(
)
bar_chart.
add_xaxis
(
x_data
)
bar_chart.
add_yaxis
(
"Sales"
,
y_data
)
Configure the chart
bar_chart.
set_global_opts
(
title_opts
=
opts.
TitleOpts
(
title
=
"Monthly Sales Bar Chart"
)
,
xaxis_opts
=
opts.
AxisOpts
(
name
=
"Month"
)
,
yaxis_opts
=
opts.
AxisOpts
(
name
=
"Sales (ten thousand yuan)"
)
,
)
Render the chart
bar_chart.
render
(
"bar_chart.html"
)
Explanation:
Bar(): Create a bar chart object.add_xaxis(): Add the x-axis data, which in this example is the months.add_yaxis(): Add the data series, which in this example is the sales for each month.set_global_opts(): Set the chart's global options.opts.TitleOpts(): Set the chart title.opts.AxisOpts(): Set properties such as the axis names.render(): Render the chart as an HTML file.
The generated chart will be saved as bar_chart.html , which can be opened directly in a browser.

Using themes
pyecharts ships with several built-in chart themes that let you quickly adjust the background, colors and overall style.
For example, you can use ThemeType.LIGHT to create a light theme, or ThemeType.DARK to create a dark theme.
The theme must be specified when the chart is created, through the opts.InitOpts() The theme parameter, rather than being changed through set_global_opts() afterwards.
The following example shows how to create a bar chart with a dark theme:
Example
from
pyecharts
import
options
as
opts
from
pyecharts.
charts
import
Bar
from
pyecharts.
globals
import
ThemeType
Prepare data
x_data
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
]
y_data
=
[
10
,
20
,
15
,
25
,
30
]
Create a bar chart and specify a dark theme
bar_chart
=
Bar
(
init_opts
=
opts.
InitOpts
(
theme
=
ThemeType.
DARK
)
)
Add data
bar_chart.
add_xaxis
(
x_data
)
bar_chart.
add_yaxis
(
"Sales"
,
y_data
)
Configure the chart
bar_chart.
set_global_opts
(
title_opts
=
opts.
TitleOpts
(
title
=
"Monthly Sales Bar Chart"
)
,
xaxis_opts
=
opts.
AxisOpts
(
name
=
"Month"
)
,
yaxis_opts
=
opts.
AxisOpts
(
name
=
"Sales (ten thousand yuan)"
)
,
)
Render the chart
bar_chart.
render
(
"themed_bar_chart.html"
)
The code above specifies the dark theme through ThemeType.DARK . To use a light theme instead, simply change the parameter used when creating the chart to:
bar_chart = Bar(
init_opts=opts.InitOpts(theme=ThemeType.LIGHT)
)
Explanation:
ThemeType: The theme type constants provided by pyecharts.opts.InitOpts(): Used to set chart initialization options such as theme, width and height.theme=ThemeType.DARK: Specifies the dark theme.theme=ThemeType.LIGHT: Specifies the light theme.
The generated chart is shown below:

Note: pyecharts themes are normally specified when the chart is created. To change the theme, modify the parameters in InitOpts and regenerate the chart.
Here are the common themes in pyecharts:
Light Themes:
ThemeType.LIGHT: A bright theme.ThemeType.WHITE: A clean white theme.ThemeType.WESTEROS: A fresh color scheme dominated by blue.ThemeType.ESSOS: A theme dominated by warm colors.ThemeType.INFOGRAPHIC: An infographic-style theme.ThemeType.MACARONS: Soft macaron colors.ThemeType.SHINE: A bright, vivid color scheme.ThemeType.ROMA: A theme combining red, gray and similar colors.ThemeType.VINTAGE: A retro color theme.ThemeType.WALDEN: A theme based on natural colors such as blue and green.ThemeType.WONDERLAND: A fresh, colorful theme.ThemeType.ROMANTIC: A romantic, soft theme.
Dark Themes:
ThemeType.DARK: A dark background theme.ThemeType.CHALK: A chalk-style theme with a dark background.ThemeType.PURPLE_PASSION: A deep purple theme.
The above grouping is based on common visual styles; the actual colors and rendering effect should be checked in the real output.
To further customize chart colors, you can also use InitOpts、set_colors() and other style options to adjust the chart's appearance.
Set global options
set_global_opts() is the pyecharts method for setting global chart options, including the title, axes, legend, tooltip, toolbox and more.
These options let the chart present more information and improve readability and interactivity.
Here are some commonly used global options:
bar_chart.set_global_opts(
title_opts=opts.TitleOpts(
title="Monthly Sales Bar Chart",
subtitle="Subtitle"
),
xaxis_opts=opts.AxisOpts(name="Month"),
yaxis_opts=opts.AxisOpts(name="Sales (10,000 yuan)"),
legend_opts=opts.LegendOpts(
pos_left="center",
pos_top="top"
),
toolbox_opts=opts.ToolboxOpts(),
tooltip_opts=opts.TooltipOpts(
trigger="axis",
axis_pointer_type="cross"
),
)
Explanation:
title_opts: Title options; sets the main title, subtitle and their styles.xaxis_opts: X-axis options; sets the horizontal axis name, labels, ticks and more.yaxis_opts: Y-axis options; sets the vertical axis name, labels, ticks and more.legend_opts: Legend options; controls the legend's position, visibility and style.toolbox_opts: Toolbox options; adds features such as data view and save as image.tooltip_opts: Tooltip options; controls the data shown on hover and the interaction behavior.
Note that some options only apply to specific chart types; for example xaxis_opts and yaxis_opts is mainly used for charts with axes.
The following example shows how to use several global options to create a bar chart with a title, legend, tooltip and toolbox:
Example
from
pyecharts
import
options
as
opts
from
pyecharts.
charts
import
Bar
Prepare data
x_data
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
]
y_data
=
[
10
,
20
,
15
,
25
,
30
]
Create the bar chart
bar_chart
=
Bar
(
)
bar_chart.
add_xaxis
(
x_data
)
bar_chart.
add_yaxis
(
"Sales"
,
y_data
)
Configure global properties
bar_chart.
set_global_opts
(
title_opts
=
opts.
TitleOpts
(
title
=
"Monthly Sales Bar Chart"
,
subtitle
=
"Unit: ten thousand yuan"
)
,
xaxis_opts
=
opts.
AxisOpts
(
name
=
"Month"
)
,
yaxis_opts
=
opts.
AxisOpts
(
name
=
"Sales (ten thousand yuan)"
)
,
legend_opts
=
opts.
LegendOpts
(
pos_left
=
"center"
,
pos_top
=
"top"
)
,
toolbox_opts
=
opts.
ToolboxOpts
(
is_show
=
True
)
,
tooltip_opts
=
opts.
TooltipOpts
(
trigger
=
"axis"
,
axis_pointer_type
=
"cross"
)
,
)
Render the chart
bar_chart.
render
(
"global_options_bar_chart.html"
)
The example above uses set_global_opts() to configure the chart title, axes, legend, toolbox and tooltip.
Wheretoolbox_opts displays the chart toolbox, andtooltip_opts lets users view the corresponding data when hovering with the mouse.
The generated chart is shown below:

Official documentation:https://pyecharts.org/#/zh-cn/intro
GitHub project:https://github.com/pyecharts/pyecharts