(8) White learn Python - pyecharts entry

Summary:

pyecharts library is used to generate a graph Echarts. 

echarts Baidu is a data visualization JS libraries open, mainly for data visualization. pyecharts library is used to generate a graph Echarts. In fact, docking Echarts and Python.

Use pyecharts can generate a separate web page, may also be used integrated in a flask, Django in.

 

characteristic:

 

Simple API design, such as silky smooth, support for chained calls

30+ kinds of common chart encompasses everything

Notebook supports mainstream environment, Jupyter Notebook and JupyterLab

It can be easily integrated into Flask, Django Web framework and other mainstream

Highly flexible configuration options, you can easily match the beautiful chart

Detailed documentation and samples to help developers get started faster project

Up to 400 + map files and native Baidu map, geographic data visualization to provide strong support

 

pip install

CMD: pip install pyecharts

 

 Display successfully, represents a successful installation, the current version is 1.4.0

Pyecharts chart included

  Bar (Histogram / bar)
  Bar3D (3D histogram)
  Boxplot for (a box plot)
  EffectScatter (scattergram with ripples animation effects)
  Funnel (FIG funnel)
  Gauge (dashboard)
  Geo (geographic coordinate system)
  Graph (diagram)
  HeatMap (FIG heat)
  Kline (line K in FIG.)
  line (polygonal line / area chart)
  Line3D (FIG. 3D polyline)
  Liquid (FIG water polo)
  the map (map)
  parallel (parallel to the coordinate system)
  pie (pie)
  the Polar ( polar coordinate system)
  radar (radar chart)
  Sankey (Sankey diagram)
  Scatter (scatter plot)
  Scatter3D (3D scatter plot)
  ThemeRiver (Figure topics river)
  wordcloud (word cloud)

  user-defined

  Grid class: parallel display multiple map
  Overlap categories: binding different types of charts superposed on the same drawing sheet of FIG
  Page class: the same page in order to show the multi FIG
  timeline class: providing a plurality of time lines in FIG rotation

Draw your first chart 

. 1  from pyecharts.charts Import Bar
 2  from pyecharts Import Options the opts AS
 . 3 bar = Bar ()
 . 4 bar.set_global_opts (title_opts = opts.TitleOpts (title = " main heading " , SUBTITLE = " subtitle " ))
 . 5 bar.add_xaxis ( [ " shirt " , " sweater " , " chiffon shirt " , " pants " , " high heels " , "Socks " ])
. 6 bar.add_yaxis ( " Business A " , [. 5, 20 is, 36, 10, 75, 90 ])
 . 7  # the render will generate a local HTML file, generates a file in the current directory render.html 
8  # can also pass path parameters, such as bar.render ( "mycharts.html") 
. 9 bar.render ()

Transform theme 

 1 from pyecharts.charts import Bar
 2 from pyecharts import options as opts
 3 # 内置主题类型可查看 pyecharts.globals.ThemeType
 4 from pyecharts.globals import ThemeType
 5 bar = (
 6     Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
 7     .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
 8     .add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
 9     .add_yaxis("商家B", [15, 6, 45, 20, 35, 66])
10     .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
11 )
12 bar.render()

 

 

 pyecharts 提供了 10+ 种内置主题,开发者也可以定制自己喜欢的主题,https://pyecharts.org/#/zh-cn/themes

(WHITE、LIGHT、DARK、CHALK、ESSOS、MACARONS、PURPLE_PASSION、ROMA、ROMANTIC、SHINE、VINTAGE、WALDEN、WESTEROS、WONDERLAND)

 

未完待续……

Guess you like

Origin www.cnblogs.com/adam012019/p/11391039.html