Pyecharts profile

Echarts is an open source data visualization by Baidu, with good interaction, exquisite chart design, has been recognized by many developers. Python, on the other hand, is an expressive language that is well suited for data processing. When data analysis meets data visualization, Pyecharts was born. (from Pyecharts website)

Python code is concise, using Pyecharts to present current events. Beginners who want to do data visualization can use this example to get started.

PS: If you need Python learning materials, please click on the link below to obtain them

Free Python learning materials and group communication solutions click to join

Preparation:

2. Open CMD and run any of the following commands based on your Python version to install Numpy and Pyecharts 0.1.9.4

PIP install numpy, pyecharts==0.1.9.4 1 PIP install numpy, Pyecharts ==0.1.9.4 1 PIP install numpy, Pyecharts ==0.1.9.4 1Copy the code

3. Prepare epidemic data of all provinces and cities in China. In this case, alipay platform was used for cumulative confirmed data statistics of all provinces and cities (up to 2020-10-18).

In the code

from pyecharts import Map import numpy as np value = np.array([68139, 1283, 1877, 1281, 586, 1019, 991, 937, 724, 1080, 845, 260, 669, 171, 280, 935, 417, 434, 948, 368, 211, 251, 208, 275, 170, 5220, 147, 157, 75, Attr = [" hubei province ", "zhejiang province", "guangdong province", "henan province", "chongqing", "hunan province", "anhui province", "Beijing", "sichuan province", "Shanghai", "shandong province", "guangxi", "jiangsu province", "hainan", "liaoning province", "jiangxi province", "fujian province", "shanxi", "heilongjiang province", "hebei province", "yunnan", "tianjin", "Shanxi Province", "Inner Mongolia The ancient ", "gansu province," "Hong Kong", "guizhou", "jilin", "the ningxia," "Taiwan", "xinjiang", "qinghai"] map = map (" at the cumulative confirmed 2020-10-18 statistics, "width = 1000, height=800) map.add("",attr,value,is_map_symbol_show=True,maptype="china", is_visualmap=True, visual_text_color='#000',is_label_show=True, Visual_range =[np.min(value),np.max(value)]) map.render()# )# program end prompt.Copy the code

The results of

The final results are exported in.html format and generally saved on the desktop after the program is run. The result is as follows:

! [](https://p1.pstatp.com/origin/pgc-image/4b062d22f152468fa7867716e2f3004e)

The picture is dynamic mouse to any provinces and cities, will change color, and the corresponding number.

Here’s another full picture. 😀

! [](https://p9-tt-ipv6.byteimg.com/large/pgc-image/7d593ea805af4887a2db29d37c3fe04f)

Very simple, no