TUTORIAL — PYTHON — PYECHARTS
How to Create Web-Friendly Charts with Apache ECharts and Python
A step-by-step tutorial on using PYECHARTS to create Apache ECharts with Python and JavaScript

Introduction
Hi, I am Gregor, a consultant and technical nerd who is very much interested in data visualization and data science. I am always looking for new and quicker ways to show information hidden in data. I often handle data with Python (Pandas) or R (Tidyverse).
Usually, the result of such an exercise is plots saved as images that end up in a PowerPoint document presented to clients. Since these are static images, additional information is provided as text as part of the PowerPoint document.
Recently I discovered Apache ECharts, an open-source tool to visualize data on the web using JavaScript. Using Apache ECharts instead of Python’s matplotlib gives you these benefits:
- Built-in interactions and automatically generated chart description
- Web-Friendly, i.e., works on desktop and mobile
- Elegant out of the box

Since Apache ECharts would require me to program JavaScript, I looked into available Python APIs. pyecharts is a Python API to create necessary HTML and JavaScript code using Python.
This article will introduce you to Apache ECharts and pyecharts, a Python library to create Apache ECharts. I will also show you how to set up your setup and walk you through two examples.
Apache Echarts & PYECHARTS
Apache ECharts
Apache EChartsTM is an open-sourced JavaScript visualization tool which can run fluently on PC and mobile devices. It is compatible with most modern Web Browsers, e.g., IE9/10/11, Chrome, Firefox, Safari and so on.

In other words, you can program your data visualizations using JavaScript directly on your HTML pages. Apache ECharts provides the necessary library so that any visitor’s browser to your website can render the visualization. The result is a dynamic and interactive graph (cf. video above).
Apache ECharts offers commonly-used chart types as a data visualization library, including line graphs, bar charts, maps, and treemaps.

pyecharts
Programming with JavaScript might scare you if you are accustomed to creating your visualization programmatically with R, Python, or Julia. Pyecharts is a Python library that allows you to create Apache EChart-compatible JavaScript files for your data visualization. This saves you from learning JavaScript and staying in your programming environment. Next to pyecharts, there are wrappers available for R and Julia.
Setup
Before we get started, you need to install pyecharts using pip.
pip install pyecharts
For this tutorial, I also make use of the beautiful Gapminder dataset. Gapminder’s data is released under the Creative Commons Attribution 3.0 Unported license. I kindly refer to these articles to learn more about it: 7 Data Wrangling Python Functions in under 5 Minutes and How to use Color Palettes for your Data Visualization.
Tutorial
Next, we need to import the necessary libraries.








