[learning notes] Python - pyecarts

SAP swordsman 2021-11-25 14:04:05
learning notes python pyecarts

pyecharts

pyecharts It's a will python And echarts Combined with powerful data visualization tools .echarts Baidu open source is a data visualization JS library , Mainly used for data visualization , and pyecharts Is a for generating echarts Class library for diagrams .

pyecharts Include the following charts :

  • Bar( Histogram / Bar chart )
  • Bar3D(3D Histogram )
  • Boxplot( Box chart )
  • EffectScatter( Scatter with ripple effect animation )
  • Funnel( Funnel diagram )
  • Gauge( The dashboard )
  • Geo( Geographic coordinate system )
  • Graph( The diagram )
  • HeatMap( Heat map )
  • Kline(K Line graph )
  • Line( Broken line / Area map )
  • Line3D(3D Broken line diagram )
  • Liquid( Water polo )
  • Map( Map )
  • Parallel( Parallel coordinate system )
  • Pie( The pie chart )
  • Polar( Polar system )
  • Radar( Radar map )
  • Sankey( Sanguitu )
  • Scatter( Scatter plot )
  • Scatter3D(3D Scatter plot )
  • ThemeRiver( Thematic River map )
  • WordCloud( Clouds of words )

Through the command “pip install pyecharts” Installation .

Clouds of words -WordCloud

Word cloud chart is a kind of chart used to show high-frequency keywords , It's through words 、 Color 、 The matching of graphics produces a very powerful visual effect , Use pyecharts Module WordCloud() Function drawing dashboard .

Example : Show the picture of words according to the box office results of the film .

import pandas as pd
import pyecharts.options as opts
from pyecharts.charts import WordCloud
# from Excel in Sheet1 Read the ranking list of Chinese film history
data = pd.read_excel(' Movie box office charts .xlsx',sheet_name='Sheet1')
name = data[' The movie name ']
value = data[' Historical box office ( One hundred million yuan )']
# Package the list into tuples , Then these tuples form a list
data1 = [i for i in zip(name,value)]
# Create a blank word cloud
chart = WordCloud()
# Set the outline and font size range of the word cloud graph
chart.add(' box office ( Billion )',data_pair=data1,shape='circle',word_size_range=[10,60])
# Add and set chart title for word cloud
chart.set_global_opts(title_opts=opts.TitleOpts(title=' Analysis of historical box office ranking of Chinese films ',title_textstyle_opts=opts.TextStyleOpts(font_size=30)),tooltip_opts=opts.TooltipOpts(is_show=True))
# Save the results as a web page
chart.render(' Analysis of historical box office ranking of Chinese films .html')

The dashboard -Gauge

The instrument cluster is suitable for displaying a single percentage , Use pyecharts Module Gauge() Function drawing dashboard .

Example : Draw the dashboard according to the completion rate of business indicators .

import pyecharts.options as opts
from pyecharts.charts import Gauge
# Create an empty dashboard
chart = Gauge()
# Add data and style the dashboard
chart.add(series_name=' Business indicators ',data_pair=[(' Achievement rate ',69.79)],split_number=10,radius='75%',start_angle=225,end_angle=-45,is_clock_wise=True,title_label_opts=opts.GaugeTitleOpts(font_size=30,color='red',font_family='Micorsoft YaHei'),detail_label_opts=opts.GaugeDetailOpts(is_show=False))
# Hide the legend and set the prompt box
chart.set_global_opts(legend_opts=opts.LegendOpts(is_show=False),tooltip_opts=opts.TooltipOpts(is_show=True,formatter='{a}<br/>{b}:{c}%'))
# Save the results as a web page
chart.render(' The dashboard .html')

Funnel diagram -Funnel

The funnel chart is used to present the data from top to bottom , The data of each stage gradually becomes smaller , Use pyecharts Module Funnel() Function to draw a funnel diagram .

Example : Use the funnel chart to show the change of the number of people on an e-commerce website from browsing goods to completing transactions .

import pyecharts.options as opts
from pyecharts.charts import Funnel
# x Coordinate data
x = [' Browse products ',' Plus shopping cart ',' Generate order ',' Pay to complete ',' Close of transaction ']
# y Coordinate data
y = [8500,6000,3200,1800,1050]
# Package the list into tuples , Then these tuples form a list
data = [i for i in zip(x,y)]
# Create an empty funnel diagram
chart = Funnel()
# Add a series name to the chart , Series data values and prompt box
chart.add(series_name=' The number of ',data_pair=data,label_opts=opts.LabelOpts(is_show=True,position='inside'),tooltip_opts=opts.TooltipOpts(trigger='item',formatter='{a}:{c}'))
# Add a title and hide the legend
chart.set_global_opts(title_opts=opts.TitleOpts(title=' E-commerce website traffic conversion funnel chart ',pos_left='center'),legend_opts=opts.LegendOpts(is_show=False))
# Save the results as a web page
chart.render(' Funnel diagram .html')

 

版权声明
本文为[SAP swordsman]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/11/20211109013804475f.html

  1. Utilisez Python pour proposer l'année de la colonne de date dans les deux CSV, faire une nouvelle colonne, puis combiner les deux tableaux CSV en un seul tableau avec la colonne de date et le numéro d'identification.
  2. 关于#python#的问题,请各位专家解答!
  3. ***
  4. ***
  5. 關於#python#的問題,請各比特專家解答!
  6. S'il vous plaît répondre aux questions de Python!
  7. About the import of Python class
  8. Magic Python property decorator: 1 line of code makes Python methods become properties in seconds
  9. Python 音频调整音量(附代码) | Python工具
  10. Python programming ideas [series of articles]
  11. Python crawler programming idea (67): modify nodes using pyquery
  12. Python crawler programming idea (66): using pyquery to obtain node information
  13. Python crawler programming idea (65): find nodes using pyquery
  14. Python crawler programming idea (64): using CSS selectors in pyquery
  15. Python crawler programming idea (63): basic knowledge of pyquery
  16. Python crawler programming idea (62): project practice: capturing cool dog online red song list
  17. Python crawler programming idea (61): project practice: capturing rental information
  18. Python crawler programming idea (60): get CSS selector code through browser
  19. Python爬虫编程思想(85):在Python中使用非关系型数据库
  20. Volume de réglage audio Python (avec Code) | outils Python
  21. Python crawler programming idea (59): get attribute value and text with beautiful soup CSS selector
  22. Python crawler programming idea (58): nested selection nodes with beautiful soup CSS selectors
  23. Python crawler programming idea (57): basic usage of CSS selector in beautiful soup
  24. Python crawler programming idea (56): find method of beautiful soup method selector
  25. Python crawler programming idea (55): find of beautiful soup method selector_ All method
  26. Python crawler programming idea (54): use beautiful soup to select sibling nodes
  27. Python crawler programming idea (53): use beautiful soup to select the parent node
  28. Django3.0 solves the problem of error reporting in reverse parsing
  29. Precautions for Python crawler
  30. Python 3 crawler series (1) -- climbing blind date websites
  31. Python到底是什么?为什么要学Python?
  32. #yyds干货盘点#Pandas数据清洗实用指南
  33. Python打包exe文件无法运行
  34. Two common ways to save files in Python
  35. #yyds幹貨盤點#Pandas數據清洗實用指南
  36. Yyds Dry Inventory pandas Data Cleaning Practical Guide
  37. PYTHON用LSTM长短期记忆神经网络的参数优化方法预测时间序列洗发水销售数据
  38. Python集成学习:自己编写构建AdaBoost分类模型可视化决策边界及sklearn包调用比较
  39. Python 3 makes a search software
  40. Python 3 simulated microblog login
  41. Using Python 3 to make practical software for drawing modification
  42. About HTML (acceptable to Python)
  43. Python集成學習:自己編寫構建AdaBoost分類模型可視化决策邊界及sklearn包調用比較
  44. PYTHON用LSTM長短期記憶神經網絡的參數優化方法預測時間序列洗發水銷售數據
  45. Python Integrated Learning: Writing and Constructing adaboost Classification Model Visualized decision Boundary and sklearn package Calling Comparison
  46. Python prédit les données de vente de shampooing de séries chronologiques en utilisant la méthode d'optimisation des paramètres du réseau neuronal de mémoire à court et à long terme lstm
  47. [zero basics of Python to introduction] a prerequisite for Python preparatory knowledge -- basic coding specification of Python
  48. OpenCV对比度亮度变换竟能用来去水印(附Python/C++源码)
  49. [zero basics of Python to getting started] a prerequisite for Python preparatory knowledge -- installing the visualization tool pycharm
  50. The test modifies main.py in micro python
  51. Microphoton experimental circuit board based on mm32f3273 - does not work normally
  52. Run micropathon on mm32f3273 to test performance
  53. Design mm32f3277 micro Python experimental board with SD card
  54. Mm32f3277 corresponding interface files during microphoton migration
  55. Mm32f3277 microphoton experimental board design and software testing
  56. Making and testing mm32f3277 microphoton minimum circuit board
  57. Download mm32-link program automatically with Python simulated mouse
  58. A curriculum of "artificial intelligence Python machine learning and deep learning"
  59. Test the basic functions of mm32 microphoton test circuit board
  60. Test the basic functions of the mm32f3277 micro Python development board flying one by one