First install the module
conda install pyecharts
perhaps
pip install pyecharts
See the official website for specific operations and introduction of eckarts echarts , I also recommend W3Cschool , and pyecharts can refer to pyecharts official website , very detailed.
In the following visualization, options will be introduced first
# Batch import package from pyecharts import options as opts from pyecharts import options as opts from pyecharts.charts import Gauge, Page
1, Instrument cluster
code:
# Making a dashboard from pyecharts.charts import Gauge def gauge_base() -> Gauge: c = ( Gauge(init_opts=opts.InitOpts(page_title="South China Procurement Center")) .add( "", [("Sales achievement rate", 80)], title_label_opts=opts.LabelOpts(horizontal_align="center") ) # pos_left="center/left/right" .set_global_opts(title_opts=opts.TitleOpts(title="South China Procurement Center", pos_left="center")) ) return c gauge_base().render_notebook()
Demonstration effect:
2, Funnel chart
code:
# Funnel chart from pyecharts.charts import Funnel def funner_base() -> Funnel: c = ( Funnel(init_opts=opts.InitOpts(page_title="Proportion of daily sales in different time periods")) .add( "funnel", [z for z in zip(["19 Before point", "20 Before point", "23 Before point"], [80000, 50000, 10000])], label_opts=opts.LabelOpts(position="inside") ) .set_global_opts(title_opts=opts.TitleOpts(title="Proportion of performance in each stage", pos_left="left")) ) return c funner_base().render_notebook()
effect:
3, Node graph
code:
# Node graph from pyecharts.charts import Graph def graph_base() -> Graph: nodes = [ opts.GraphNode(name="Node 0", symbol_size=80), opts.GraphNode(name="Node 1", symbol_size=60), opts.GraphNode(name="Node 2", symbol_size=60), opts.GraphNode(name="Node 3", symbol_size=60), opts.GraphNode(name="Node 4", symbol_size=60), opts.GraphNode(name="Node 1.1", symbol_size=40), opts.GraphNode(name="Node 1.2", symbol_size=40), opts.GraphNode(name="Node 1.3", symbol_size=40), opts.GraphNode(name="Node 1.4", symbol_size=40), opts.GraphNode(name="Node 3.1", symbol_size=40), opts.GraphNode(name="Node 3.2", symbol_size=40), opts.GraphNode(name="Node 3.3", symbol_size=40), opts.GraphNode(name="Node 3.4", symbol_size=40), opts.GraphNode(name="Node 3.3.1", symbol_size=20), opts.GraphNode(name="Node 3.3.2", symbol_size=20), opts.GraphNode(name="Node 3.3.3", symbol_size=20), opts.GraphNode(name="Node 3.3.4", symbol_size=20) ] links = [ opts.GraphLink(source="Node 0", target="Node 1", value=1), opts.GraphLink(source="Node 0", target="Node 2", value=1), opts.GraphLink(source="Node 0", target="Node 3", value=1), opts.GraphLink(source="Node 0", target="Node 4", value=1), opts.GraphLink(source="Node 1", target="Node 1.1", value=2), opts.GraphLink(source="Node 1", target="Node 1.2", value=2), opts.GraphLink(source="Node 1", target="Node 1.3", value=2), opts.GraphLink(source="Node 1", target="Node 1.4", value=2), opts.GraphLink(source="Node 3", target="Node 3.1", value=2), opts.GraphLink(source="Node 3", target="Node 3.2", value=2), opts.GraphLink(source="Node 3", target="Node 3.3", value=2), opts.GraphLink(source="Node 3", target="Node 3.4", value=2), opts.GraphLink(source="Node 3.3", target="Node 3.3.1", value=3), opts.GraphLink(source="Node 3.3", target="Node 3.3.2", value=3), opts.GraphLink(source="Node 3.3", target="Node 3.3.3", value=3), opts.GraphLink(source="Node 3.3", target="Node 3.3.4", value=3), ] c = ( Graph(init_opts=opts.InitOpts(width="1080px", height="700px", page_title="chart-Demonstration")) .add( "graph", nodes, links, label_opts=opts.LabelOpts(position="inside"), repulsion=2000, is_draggable=True, layout="force", symbol="roundRect", edge_label=opts.LabelOpts( is_show=True, position="middle", formatter=" " ) ) .set_global_opts(title_opts=opts.TitleOpts(title="Figure demonstration", pos_left="center")) ) return c graph_base().render_notebook()
Effect (which can be flipped in 3D in notebook):
4, Water polo
code:
# Water polo from pyecharts.charts import Liquid def liquid_base() -> Liquid: c = ( Liquid(init_opts=opts.InitOpts(page_title="Sales completion rate")) .add( "liquid", [0.78], shape="rect" ) .set_global_opts(title_opts=opts.TitleOpts(title="Sales achieved", pos_left="center")) ) return c liquid_base().render_notebook()
effect:
5, Ring chart
code:
# Ring chart from pyecharts.charts import Pie def pie_base() -> Pie: c = ( Pie(init_opts=opts.InitOpts(page_title="Ring chart")) .add( "pie", [("19 Pre point sales", 80), ("19 Post point sales", 20)], radius=["40%", "60%"], center=["50%", "50%"], label_opts=opts.LabelOpts(formatter=":%") ) .set_global_opts( title_opts=opts.TitleOpts(title="Ring chart", pos_left="center", pos_top="10%"), legend_opts=opts.LegendOpts(orient="vertical", pos_right="20%", pos_top="50%") ) ) return c pie_base().render_notebook()
Effect:
6, Cloud of words
code:
# Cloud of words from pyecharts.charts import WordCloud def wcloud_base() -> WordCloud: words = [("Fruit group",10000), ("Rhizome seasoning group",9000), ("Mushroom group",8000), ("Leafy cabbage group",7000), ("Fresh and fresh",6000), ("Frozen products",4000), ("Ice fresh",900), ("Domestic group II",10000), ("Imported fresh fruit",15000), ("A group made in China",3000), ("Powder face pill group ",2000), ("Poultry accessories group",1000), ("Omelette group",2000), ("Cooked food conditioning group",1000),("Pork",5000),("Online retailers",1000)] c = ( WordCloud(init_opts=opts.InitOpts(page_title="Cloud of words")) .add( "wordcloud", words, shape="cardioid" ) .set_global_opts(title_opts=opts.TitleOpts(title="Cloud of words", pos_left="center")) ) return c wcloud_base().render_notebook()
effect:
7, Histogram
code:
# Column chart from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode def bar_base() -> Bar: c = ( Bar(init_opts=opts.InitOpts(page_title="2020 Sales of all departments in April")) .add_xaxis( ["Amount of aquatic products delivered/Gross profit on delivery", "Fruit delivery/Gross profit on delivery", "Vegetable stock out/Gross profit on delivery", "Comprehensive delivery amount/Gross profit on delivery"] ) .add_yaxis( "", [2450, 3900, 8947,12050] ) .add_yaxis( "", [500, 800, 1206,3045] ) .set_series_opts( itemstyle_opts={ "color":JsCode("""{ type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ , ], global: false }""" ) } ) .set_global_opts( title_opts=opts.TitleOpts(title="2020 Sales of all departments in April", pos_left="center"), legend_opts=opts.LegendOpts(orient="victical", pos_right="10%", pos_top="center") ) ) return c bar_base().render_notebook()
Effect:
8, Radar chart
code:
# 8, Radar chart from pyecharts.charts import Radar def radar_base() -> Radar: c = ( Radar(init_opts=opts.InitOpts(page_title="Radar chart")) .add_schema( schema=[ opts.RadarIndicatorItem(name="Python", max_=100), opts.RadarIndicatorItem(name="R language", max_=100), opts.RadarIndicatorItem(name="Excel Skill", max_=100), opts.RadarIndicatorItem(name="SQL language", max_=100), opts.RadarIndicatorItem(name="PhotoShop", max_=100), opts.RadarIndicatorItem(name="Windows operation", max_=100) ], shape="circle" ) .add( "My level", [[85, 75, 90, 85, 72, 75]], areastyle_opts=opts.AreaStyleOpts(opacity=0.1) ) .add( "average level ", [[60, 60, 60, 60, 60, 60]], linestyle_opts=opts.LineStyleOpts(width=2, color='blue') ) .set_global_opts( title_opts=opts.TitleOpts(title="Radar chart", pos_left="center"), legend_opts=opts.LegendOpts(pos_right="20%", pos_top="10%", orient="vectical") ) ) return c radar_base().render_notebook()
Effect:
9, Sunrise chart
It's actually a picture of the sun exploding
code:
# 9, Sunrise chart from pyecharts.charts import Sunburst def sunburst_base() -> Sunburst: data = [ opts.SunburstItem( name="data acquisition", children=[ opts.SunburstItem(name="Reptile", value=50), opts.SunburstItem(name="Exchange share", value=20), opts.SunburstItem(name="Third party purchase", value=20), opts.SunburstItem(name="Other ways", value=10) ] ), opts.SunburstItem( name="data storage ", children=[ opts.SunburstItem(name="Relational database", value=60), opts.SunburstItem(name="Key value repository", value=10), opts.SunburstItem(name="Columnar repository", value=10), opts.SunburstItem(name="Document oriented database", value=10), opts.SunburstItem(name="Figure database", value=10) ] ), opts.SunburstItem( name="data processing", children=[ opts.SunburstItem(name="Null fill", value=20), opts.SunburstItem(name="Exception handling", value=20), opts.SunburstItem(name="New features", value=20), opts.SunburstItem(name="Thermal coding", value=20), opts.SunburstItem(name="Standardized treatment", value=20) ] ), opts.SunburstItem( name="Statistical analysis of data", children=[ opts.SunburstItem(name="Descriptive analysis", value=30), opts.SunburstItem(name="Multidimensional statistics", value=40), opts.SunburstItem(name="Comparative statistics", value=30) ] ), opts.SunburstItem( name="data mining ", children=[ opts.SunburstItem(name="classification", value=30), opts.SunburstItem(name="Forecast", value=30), opts.SunburstItem(name="clustering", value=20), opts.SunburstItem(name="regression", value=20) ] ), opts.SunburstItem( name="Data display", children=[ opts.SunburstItem(name="Large screen display", value=20), opts.SunburstItem(name="System page display", value=40), opts.SunburstItem(name="Report display", value=40), ] ), opts.SunburstItem( name="Data product application", children=[ opts.SunburstItem(name="Recommendation system", value=30), opts.SunburstItem(name="translation system ", value=20), opts.SunburstItem(name="Autopilot", value=15), opts.SunburstItem(name="Face recognition", value=15), opts.SunburstItem(name="Picture recognition text", value=20) ] ) ] c = ( Sunburst(init_opts=opts.InitOpts(page_title="Sunrise chart-Demonstration")) .add( "sunburst", data, radius=["20%", "85%"] ) .set_global_opts(title_opts=opts.TitleOpts(title="Sunrise chart", pos_left="center")) ) return c sunburst_base().render_notebook()
Effect:
For more information, please refer to the official website of ecahrts or pyecharts, and recommend one echarts community There are many creative visualizations.