05 pyecharts 基本图表(示例代码+效果图)
生活随笔
收集整理的這篇文章主要介紹了
05 pyecharts 基本图表(示例代码+效果图)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
1 Pie餅圖
2 Funnel漏斗圖
3 Gauge儀表盤
4 Liquid水球圖
5 Calendar日歷圖
6 Graph關系圖
7 Parallel平行坐標系
8 Polar極坐標系
9 Radar雷達圖
10 Sunburst旭日圖
11 Sankey桑基圖
12 ThemeRiver河流圖
13 WordCloud詞云圖
14 Table表格
1 Pie餅圖
# 加QQ群和我一起討論學習吧:懶笑翻-Python學習交流資料分享群 732481539 from pyecharts.charts import Piecate = ['1月', '2月', '3月', '4月', '5月', '6月'] data = [1123, 1153, 1089, 1207, 1298, 1123]pie = (Pie().add('', [list(z) for z in zip(cate, data)])) pie.render("pie.html")2 Funnel漏斗圖
""" 學習中遇到問題沒人解答?小編創建了一個Python學習交流QQ群:732481539 尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書! """ from pyecharts.charts import Funnelcate = ['瀏覽', '查看詳情', '加入購物車', '購買', '退款'] data = [33445, 11223, 5566, 443, 32]funnel = (Funnel().add("", [list(z) for z in zip(cate, data)]))funnel.render("funnel.html")3 Gauge儀表盤
# 加QQ群和我一起討論學習吧:懶笑翻-Python學習交流資料分享群 732481539 from pyecharts.charts import Gaugegauge = (Gauge().add("溫度", [('', 38)]))gauge.render("gauge.html")4 Liquid水球圖
from pyecharts.charts import Liquidliquid = (Liquid().add("", [0.70, 0.10]))liquid.render("liquid.html")5 Calendar日歷圖
# 加QQ群和我一起討論學習吧:懶笑翻-Python學習交流資料分享群 732481539 import math import datetime from pyecharts import options as opts from pyecharts.charts import Calendarbegin = datetime.date(2022, 1, 1) end = datetime.date(2022, 12, 31) data = [[str(begin + datetime.timedelta(days=i)), abs(math.cos(i / 100)) * random.randint(1000, 1200)]for i in range((end - begin).days + 1)]calendar = (Calendar().add("", data, calendar_opts=opts.CalendarOpts(range_="2022")) )calendar.render("calendar.html")6 Graph關系圖
from pyecharts.charts import Graphnodes = [{"name": "結點1", "symbolSize": 1},{"name": "結點2", "symbolSize": 2},{"name": "結點3", "symbolSize": 3},{"name": "結點4", "symbolSize": 4},{"name": "結點5", "symbolSize": 5}, ] links = [{'source': '結點1', 'target': '結點2'},{'source': '結點1', 'target': '結點4'},{'source': '結點2', 'target': '結點1'},{'source': '結點3', 'target': '結點4'},{'source': '結點3', 'target': '結點2'},{'source': '結點4', 'target': '結點1'},{'source': '結點5', 'target': '結點1'},{'source': '結點5', 'target': '結點4'},]graph = (Graph().add("", nodes, links) )graph.render("graph.html")7 Parallel平行坐標系
from pyecharts.charts import Paralleldata = [['孫悟空', 68, 61, 63, 68, 62, 67, "及格"],['牛魔王', 88, 81, 83, 88, 82, 87, "良好"],['豬八戒', 58, 51, 53, 58, 42, 37, "不及格"],['嫦娥', 78, 71, 73, 78, 72, 77, "中等"],['魯班', 98, 91, 123, 98, 92, 97, "優秀"],]parallel = (Parallel().add_schema([opts.ParallelAxisOpts(dim=0,name="班級",type_="category",data=["孫悟空", "牛魔王", "豬八戒", "嫦娥", "魯班"],),opts.ParallelAxisOpts(dim=1, name="英語"),opts.ParallelAxisOpts(dim=2, name="數學"),opts.ParallelAxisOpts(dim=3, name="語文"),opts.ParallelAxisOpts(dim=4, name="物理"),opts.ParallelAxisOpts(dim=5, name="生物"),opts.ParallelAxisOpts(dim=6, name="化學"),opts.ParallelAxisOpts(dim=7,name="評級",type_="category",data=["優秀", "良好", "合格"],),]).add("", data) )parallel.render("parallel.html")8 Polar極坐標系
from pyecharts.charts import Polarcate = ['1月', '2月', '3月', '4月', '5月', '6月'] data = [800, 953, 1089, 1207, 1400, 1123]polar = (Polar().add_schema(radiusaxis_opts=opts.RadiusAxisOpts(data=cate, type_="category"),).add("月消費", data, type_='bar') )polar.render('polar.html')9 Radar雷達圖
from pyecharts.charts import Radardata = [[68, 61, 63, 68, 62, 67],[88, 81, 83, 88, 82, 87],[58, 51, 53, 58, 42, 37],[78, 71, 73, 78, 72, 77],[98, 91, 123, 98, 92, 97] ]radar = (Radar().add_schema(schema=[opts.RadarIndicatorItem(name="語文", max_=150),opts.RadarIndicatorItem(name="數學", max_=150),opts.RadarIndicatorItem(name="英語", max_=150),opts.RadarIndicatorItem(name="物理", max_=100),opts.RadarIndicatorItem(name="生物", max_=100),opts.RadarIndicatorItem(name="化學", max_=100), ] ).add('', data)) radar.render('radar.html')10 Sunburst旭日圖
# 旭日圖 from pyecharts.charts import Sunburstdata = [{"name": "湖南","children": [{"name": "長沙","children": [{"name": "雨花區", "value": 55},{"name": "岳麓區", "value": 34},{"name": "天心區", "value": 144},{"name": "芙蓉區", "value": 111},{"name": "開福區", "value": 84},{"name": "望城區", "value": 99},]},{"name": "常德","children": [{"name": "武陵區", "value": 156},{"name": "鼎城區", "value": 134},]},{"name": "湘潭", "value": 87},{"name": "株洲", "value": 23},],},{"name": "湖北","children": [{"name": "武漢","children": [{"name": "洪山區", "value": 55},{"name": "東湖高新", "value": 78},{"name": "江夏區", "value": 34},]},{"name": "鄂州", "value": 67},{"name": "襄陽", "value": 34},],},{"name": "臺灣", "value": 235} ]sunburst = (Sunburst().add("", data_pair=data))sunburst.render('sunburst.html')11 Sankey桑基圖
from pyecharts.charts import Sankeynodes = [{"name": "訪問"},{"name": "關注"},{"name": "付費"}, ]links = [{"source": "訪問", "target": "關注", "value": 150},{"source": "關注", "target": "付費", "value": 60}, ]sankey = (Sankey().add("", nodes, links) )sankey.render('sankey.html')12 ThemeRiver河流圖
from pyecharts.charts import ThemeRivercate = ['1月', '2月', '3月', '4月', '5月', '6月'] date_list = ["2022/6/{}".format(i + 1) for i in range(30)]data = [[day, random.randint(10, 200), c] for day in date_list for c in cate]river = (ThemeRiver().add(series_name=cate,data=data,singleaxis_opts=opts.SingleAxisOpts(type_="time")) )river.render('river.html')13 WordCloud詞云圖
from pyecharts.charts import WordCloudwords = [("在嗎", 230),("早啊", 124),("晚安", 436),("吃了嗎", 255),("學習", 247),("哈哈", 244),("笑死", 138),("上課", 184),("憨批", 12),("抱抱", 165),("作業", 247),("放假", 182),("禮物", 25),("寶貝", 365),("今天", 173),("呵呵", 65), ]wordCloud = (WordCloud().add("", words) )wordCloud.render('wordCloud.html')14 Table表格
from pyecharts.components import Tabletable = Table()headers = ["City name", "Area", "Population", "Annual Rainfall"] rows = [["Brisbane", 5905, 1857594, 1146.4],["Adelaide", 1295, 1158259, 600.5],["Darwin", 112, 120900, 1714.7],["Hobart", 1357, 205556, 619.5],["Sydney", 2058, 4336374, 1214.8],["Melbourne", 1566, 3806092, 646.9],["Perth", 5386, 1554769, 869.4], ] table.add(headers, rows)table.render('table.html')總結
以上是生活随笔為你收集整理的05 pyecharts 基本图表(示例代码+效果图)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: arcgis怎么压缩tif文件_PDF文
- 下一篇: 如何定制B2C电商网站