from pyecharts import Pie attr =["襯衫","羊毛衫","雪紡衫","褲子","高跟鞋","襪子"] v2 =[19,25,32,20,22,33] pie = Pie("餅圖-玫瑰圖示例",title_pos="left , width=750,height= 300") pie.add("商品B" ,attr,v2,center=[50,50],is_random=True,radius=[30, 75],rosetype='area',is_legend_show=False, is_label_show=True) pie
問題1:ModuleNotFoundError: No module named 'pyecharts'
解決:
1、下載whl文件鏈接:https://pypi.org/project/pyecharts/#files
官網下載最新版下載whl文件
2、將下載的whl文件放在安裝路徑 scripts中【\python35\python-3.5.4-amd64\Scripts】
3.打開命令行,操作界面,進入\python35\python-3.5.4-amd64\Scripts路徑,執行pip install pyecharts-1.9.0-py3-none-any.whl進行安裝
問題2:ImportError: cannot import name 'Pie' from 'pyecharts'
解決:安裝的pyecharts版本過高,可以卸載pyecharts,安裝
PYECHARTS==0.5.11
命令:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyecharts==0.5.11
上述操作后又報:ModuleNotFoundError: No module named 'pyecharts_snapshot'
解決:安裝pip install pyecharts_snapshot
# coding=utf-8 from __future__ import unicode_literals from pyecharts import Pie attr = ["襯衫", "羊毛衫", "雪紡衫", "褲子", "手套"] v2 = [10, 20, 30, 40, 20] pie = Pie("餅圖-玫瑰圖示例", "來自京東數據", title_pos="left , width=750,height= 300") pie.add("商品B", # name -> str 圖例名稱 attr, # attr -> list 列表形式 屬性名稱 v2, # value -> list 屬性所對應的值 center=[50, 50], # -> list餅圖的中心(圓心)坐標,數組的第一項是橫坐標,第二項是縱坐標,默認為 [50, 50]默認設置成百分比,設置成百分比時第一項是相對於容器寬度,第二項是相對於容器高度 radius=[30, 75], # radius -> list 餅圖的半徑,數組的第一項是內半徑,第二項是外半徑,默認為 [0, 75],默認設置成百分比,相對於容器高寬中較小的一項的一半 is_random=True, # 顏色或樣式隨機 rosetype='radius', # rosetype -> str是否展示成南丁格爾圖,通過半徑區分數據大小,有'radius'和'area'兩種模式。默認為'radius' # radius:扇區圓心角展現數據的百分比,半徑展現數據的大小 # area:所有扇區圓心角相同,僅通過半徑展現數據大小 is_legend_show=True, # 屬性標簽 is_label_show=True) # 屬性標簽在扇形環上面展示 pie.render(path="C:\\Users\\Administrator\\Desktop\\**\\Bing2.html")