Big Data 9 min read

Using pyecharts in Python to Create Various Interactive Charts

This tutorial explains how to use the pyecharts library—a Python wrapper for Baidu's ECharts—to generate a wide range of interactive visualizations, including bar, line, pie, map, heatmap, scatter, 3D, and combined charts, with complete code examples and rendering instructions for Jupyter notebooks.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Using pyecharts in Python to Create Various Interactive Charts

pyecharts combines Python with Baidu's open‑source ECharts library, enabling developers to create rich, interactive data visualizations directly from Python code.

The article walks through the creation of many common chart types—bar, line, area, pie, rose, funnel, heatmap, scatter, 3D scatter, boxplot, map, geo heatmap, world map, word cloud, and a combined grid chart—showing how to import the required classes, generate sample data, configure chart options, and render the results in a notebook.

For each chart a self‑contained code snippet is provided; for example, a basic bar chart is built as follows:

from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker

c = (
    Bar()
    .add_xaxis(Faker.choose())
    .add_yaxis("商家A", Faker.values())
    .add_yaxis("商家B", Faker.values())
    .set_global_opts(title_opts=opts.TitleOpts(title="Bar‑MarkLine(自定义)"))
    .set_series_opts(label_opts=opts.LabelOpts(is_show=False),
                     markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(y=50, name="yAxis=50")]))
)
c.render_notebook()

Similar patterns are used for other chart types, adjusting the chart class (e.g., Line() , Pie() , HeatMap() ), adding appropriate axes and series, and customizing global options such as title_opts , visualmap_opts , and legend_opts . The final combined chart demonstrates overlapping a bar and line chart on a shared grid with multiple Y‑axes.

All examples conclude with .render_notebook() to display the interactive chart within a Jupyter environment.

tutorialdata visualizationechartspyechartscharts
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.