def test_funnel_labelpos_inside(): funnel = Funnel("漏斗图示例") funnel.add( "商品", CLOTHES, prices, is_label_show=True, label_pos="inside", label_text_color="#fff", ) funnel.render()
def test_funnel_other_style(): funnel = Funnel("漏斗图示例", title_pos="center") funnel.add( "商品", CLOTHES, prices, is_label_show=True, label_pos="outside", legend_orient="vertical", legend_pos="left", ) funnel.render()
def drawFunnel(title, data, savepath='./results'): if not os.path.exists(savepath): os.mkdir(savepath) funnel = Funnel(title, title_pos='center') funnel.use_theme('chalk') attrs = [i for i, j in data.items()] values = [j for i, j in data.items()] funnel.add("", attrs, values, is_label_show=True, label_pos="inside", label_text_color="#fff", legend_pos="left", legend_orient="vertical") funnel.render(os.path.join(savepath, '%s.html' % title))
def funnel(self, title=None, attr=None, value=None, two_title=None): """ 漏斗图 :param title: 数据可视化的标题(字符串) :param attr: 名称列表[列表] :param value: 名称列表对应数据 :param two_title: 二级小标题(鼠标悬浮显示小标题) :return:漏斗图 """ attr2 = attr value = value funnel = Funnel(title) funnel.add(two_title, attr2, value, is_label_show=True, label_pos='inside', label_text_color='#fff') self.page.add(funnel) self.page.render()
def get_salary(self, df): money = df["薪资"].apply(lambda x: np.array( x.replace("k", "").replace("K", "").split("-")).tolist()) money = money.apply(lambda x: (int(x[0]) + int(x[1])) / 2) # 重新分类薪资区间范围 df["薪资"] = pd.cut( money, bins=[0, 10, 20, 25, 30, 100], right=False, labels=np.array(["0-10k", "10k-20k", "20k-25k", "25k-30k", "30K+"])) data = df["薪资"].value_counts() funnel = Funnel("工程师薪资分布图", title_pos="center") funnel.add( name="薪资分布", attr=data.index, value=data.values, is_label_show=True, label_formatter='{b} {d}%', label_pos='inside', legend_orient='vertical', legend_pos='right', ) funnel.render(self.html_path + "salary.html") draw_pie(self.html_path + "salaryPie.html", "薪资分布", data.index, data.values)
def funnel_orientataion(self): orientation = pd.read_csv(self.all_house_path, encoding='utf-8') orientation = orientation.groupby(by='orientation').count() orientation = orientation['price'].sort_values(ascending=False) attr = orientation.index value = orientation.values index = [] values = [] for i in attr: index.append(i) for i in value: values.append(i) # print(len(index), len(value)) funnel_orien = Funnel("房源朝向漏斗图", width=800, height=700, title_pos="center") funnel_orien.add( "朝向", attr, value, is_label_show=True, label_pos="outside", legend_pos="left", label_text_color="#000", legend_orient="vertical", funnel_gap=5, ) funnel_orien.render(path="funnel-orientataion.html")
def dan_wang(self): """ 获取淡旺季电影 :return: """ pro = self.get_pro() month_l = [] amount_l = [] for month in self.month_list: df = pro.bo_monthly(date=month) month_amount = df['month_amount'].sum() mon = f"{month[4:6]}月份" month_l.append(mon) amount_l.append(month_amount) funnel = Funnel("") funnel.add( "商品", month_l, amount_l, is_label_show=True, label_pos="inside", label_text_color="#fff", ) funnel.render(path="淡旺季.html", )
def loudoutu(): '''漏斗图''' attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render('./info/漏斗图.html')
def test_funnel_labelpos_inside(): funnel = Funnel("漏斗图示例") funnel.add("商品", CLOTHES, prices, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render()
def test_funnel_other_style(): funnel = Funnel("漏斗图示例", title_pos='center') funnel.add("商品", CLOTHES, prices, is_label_show=True, label_pos="outside", legend_orient='vertical', legend_pos='left') funnel.render()
def draw_funnel(): attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render()
def draw_edu_funnel(data): funnel = Funnel("妹子学历分布漏斗图", title_top='center') funnel.add("学历", edu_interval, data, is_label_show=True, label_pos="inside", label_text_color="#fff", is_random=True) funnel.render() return funnel
def countFinalWordsList(text, new_text): new_words = new_text.split(' ') countvaluelist = [] for i in new_words: #print i count = text.count(i) countvaluelist.append(count) funnel = Funnel("论坛评论词云统计图", width=900, height=700, title_pos='center') funnel.add("论坛评论词云统计", new_words, countvaluelist, is_label_show=True, label_pos="inside", label_text_color="#fff", funnel_sort="escending") funnel.render(r'../templates/ciyuncountwords.html')
def get_top_skill(self,funnel_num=9): jieba.load_userdict('D:/编程练习题/datasite/test/analysis/user_dict.txt') unuse_keywords = ['开发', '工程师', ')', '(', ' ', '(', ')', '高级', '编号', '.', ':', '/', ':', '-', '职位', '+', '、', ',', '实习生', '..', '*', '_', '[', ']', '东莞', '3', '2', '二', '01', ',', ',', '2020', '一', '\\', '8k', '呼和浩特', '内蒙古', '07', 'ZHGAly' , 'J11797', '04', '05', '03', 'J11797', 'ZHGAljw', 'J11959', 'J12619', '对', '003', '002', '苏州', '&', '02', '.', '急聘', '应届生', '实习生', '月', '日' , '初级', '高级', '区域', '资深', '岗', '10', '实习', '五险一金', '讯飞', '大', '12K', '8K', '可', '双休', '出差', '平台', '福州', '方向', '北京', '推广' , '中级', '助理', '千', '总监', '客服', '客户', '省区', '与', '驻场', '合伙人', '商务', '专家', '讲师', '#', 'J11804', '年薪', '上市公司', '10W', '锁' , '员', '休闲', '娱乐', '医疗', '现场', '公安', '政府', '底薪', '负责人', '人事', '老师' , '五险', '一金', '重庆', '高新', '毕业生', '应届', '编程', '包', '合肥', '长期', '咨询', '师', '售后' , '小', '年', '程序员', 'RJ002', '号', '001', '个', '郑州', '武汉', '万', '招聘', '代表', '渠道', '4', '6', 'S', 'Y', '7', '5', '不' , '急', '++', '西安'] d = {} sql = 'select title,number from job' self.db.cursor.execute(sql) result = self.db.cursor.fetchall() for r in result: tmp = jieba.lcut(r[0]) for skill in tmp: if skill in unuse_keywords: continue if skill == '软件工程师': skill = '软件开发' if skill not in d.keys(): d[skill] = 0 d[skill] += int(r[1]) wordcloud = WordCloud(width=1000, height=600) wordcloud.add("", d.keys(), d.values(), word_size_range=[20, 100]) wordcloud.render(path="D:/编程练习题/datasite/test/templates/charts/wordcloud.html") d_order = sorted(d.items(), key=lambda x: x[1], reverse=True) d_order=dict(d_order[0:funnel_num]) configure(output_image=True) funnel = Funnel(background_color='white', title_text_size=20, title_pos='center',width=1000, height=600) funnel.add('教育', d_order.keys(), d_order.values(), is_label_show=True, label_pos='inside', is_legend_show=False) funnel.render(path='D:/编程练习题/datasite/test/templates/charts/career_funnel.html')
def LouDou_2017(request): number = Area_gdp.objects.get(year=2017) attr = [ "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林", "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西", "山东", "河南", "湖北", "湖南", "广东", "广西", "海南", "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃", "青海", "宁夏", "新疆" ] value = [ number.beijing, number.tianjin, number.hebei, number.shanxi, number.neimenggu, number.liaoning, number.jilin, number.heilongjiang, number.shanghai, number.jiangsu, number.zhejiang, number.anhui, number.fujian, number.jiangxi, number.shandong, number.henan, number.hubei, number.hunan, number.guangdong, number.guangxi, number.hainan, number.chongqing, number.sichuan, number.guizhou, number.yunnan, number.xizang, number.shanxi, number.gansu, number.qinghai, number.ningxia, number.xinjiang ] funnel = Funnel("2017年地区经济数据分析", width=1500, height=600, title_pos='center') funnel.add( "GDP", attr, value, is_label_show=True, label_pos="outside", label_text_color="#fff", funnel_sort="ascending", # funnel_gap=5, legend_orient="vertical", legend_pos="left", ) funnel.render( path="F:/尚世康资料/尚世康+毕业论文相关资料/系统设计/cms/templates/2017年地区经济桶状图.html") return HttpResponse("2017年桶装图已生成")
def test_funnel(): # label_pos 'inside' attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render() # label_pos 'outside'&legend_orient 'vertical' funnel = Funnel("漏斗图示例", width=600, height=400, title_pos='center') funnel.add("商品", attr, value, is_label_show=True, label_pos="outside", legend_orient='vertical', legend_pos='left') funnel.render()
spark.sql("SELECT * FROM taobao where item_id=95756656").show() # 总体转化率 sqlDF = spark.sql( "SELECT count(pv) as cpv, count(cart) as ccart, count(fav) as cfav, count(buy) as cbuy from pbcf" ) sqlDF.show() pbcfPandasDF = sqlDF.toPandas() # Python实现漏斗图的绘制 https://blog.csdn.net/qq_41080850/article/details/83933017 from pyecharts import Funnel attrs = pd.Series(['pv', 'cart', 'fav', 'buy']).tolist() attr_value = pd.Series([ 100, pbcfPandasDF.iloc[0]['ccart'] / pbcfPandasDF.iloc[0]['cpv'] * 100, pbcfPandasDF.iloc[0]['cfav'] / pbcfPandasDF.iloc[0]['ccart'] * 100, pbcfPandasDF.iloc[0]['cbuy'] / pbcfPandasDF.iloc[0]['ccart'] * 100 ]).tolist() funnel1 = Funnel("总体转化漏斗图一", width=800, height=400, title_pos='center') funnel1.add( name="商品交易行环节", # 指定图例名称 attr=attrs, # 指定属性名称 value=attr_value, # 指定属性所对应的值 is_label_show=True, # 指定标签是否显示 label_formatter='{c}%', # 指定标签显示的格式 label_pos="inside", # 指定标签的位置 legend_orient='vertical', # 指定图例的方向 legend_pos='left', # 指定图例的位置 is_legend_show=True) # 指定图例是否显示 funnel1.render() funnel1 spark.catalog.clearCache()
''' 高低分和哪位演员有关 ''' mapping = {'liucixin':'刘慈欣|大刘', 'guofan':'郭帆|郭导', 'quchuxiao':'屈楚萧|刘启|户口', 'wujing':'吴京|刘培强', 'liguangjie':'李光洁|王磊', 'wumengda':'吴孟达|达叔|韩子昂', 'zhaojinmai':'赵今麦|韩朵朵'} for key, value in mapping.items(): data[key] = data['content'].str.contains(value) # 总体提及次数 staff_count = pd.Series({key: data.loc[data[key], 'score'].count() for key in mapping.keys()}).sort_values() print(staff_count) funnel = Funnel("《流浪地球》演职员总体提及次数", width=700) funnel.add("", ['李光洁','郭帆','赵今麦','吴孟达','屈楚萧','刘慈欣','吴京'], staff_count.values, is_stack=True, is_label_show=True, legend_pos="50%",label_color = ['#677fge'],legend_text_size=8) funnel.render() page.add(funnel) average_score = pd.Series({key: data.loc[data[key], 'score'].mean() for key in mapping.keys()}).sort_values() print(average_score) bar6 = Bar("《流浪地球》演职员平均分", width=700) bar6.add("", ['赵今麦','吴孟达','屈楚萧','吴京','李光洁','刘慈欣','郭帆'], np.round(average_score.values,2), is_stack=True, is_label_show=True, bar_category_gap='60%', label_color = ['#677fge'], legend_text_size=18,xaxis_label_textsize=18,yaxis_label_textsize=18)
from pyecharts import Funnel attr = ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'] value = [20, 40, 60, 80, 100, 120] funnel = Funnel('漏斗图') funnel.add('商品', attr, value, is_label_show=True, label_pos='inside', label_text_color='#fff') funnel.render()
cun=jieba.cut(txt) #读取停用词文件 stops=open(r'D:\BI大屏\去停用词.txt','r',encoding='UTF-8').read() # 去停用词 tokens=[token for token in cun if token not in stops] d={} for i in tokens: d[i] = d.get(i,0) + 1 count_list = sorted(d.items(), key=lambda x:x[1], reverse=True) count_list = count_list[:15] keyword_list = [k[0] for k in count_list] value_list = [k[1] for k in count_list] funnel=Funnel(background_color='#404a59') #修改标题位置 funnel.use_theme("dark") #修改图表主题 funnel.add("",keyword_list, value_list, is_label_show=True, is_legend_show=False, label_pos="outside") #是否显示标签、是否显示图例、标签位置 funnel._option['series'][0]["top"]=70 #修改漏斗图上间隔 funnel._option['series'][0]["bottom"]=20 #修改漏斗图下间隔 funnel._option['series'][0]["left"]="5%" #修改漏斗图左间隔 funnel._option['series'][0]["width"]="90%" #修改漏斗图宽度 #funnel.render(r"D:\BI大屏\漏斗图.html") page.add_chart(funnel,name="funnel") #=============================================================================
import json from pyecharts import Funnel f = open("E:/Data/practice/pies.json") data = json.load(f) name = data['name'] sales = data['sales'] sales_volume = data['sales_volume'] # 漏斗图.这里传入空字符串即可没有titile funnel = Funnel("", width=800) # label_pos='inside'指明标签的位置在图的内部,label_text_color='#fff'指明标签自己颜色为白色 funnel.add("成交量", name, sales_volume, is_label_show=True, label_pos='inside', label_text_color='#fff') funnel.render("./funnel.html")
def test_funnel(): # funnel_0 attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("漏斗图示例") funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render() # funnel_1 funnel = Funnel("漏斗图示例", width=600, height=400, title_pos='center') funnel.add("商品", attr, value, is_label_show=True, label_pos="outside", legend_orient='vertical', legend_pos='left') funnel.show_config() funnel.render()
def buy_convert_rate(self): # 浏览、收藏、加入购物车、购买的用户数 pv_num = self.data[self.data['behavior_type'] == 'pv']['user_id'].count() collect_num = self.data[self.data['behavior_type'] == 'collect']['user_id'].count() cart_num = self.data[self.data['behavior_type'] == 'cart']['user_id'].count() buy_num = self.data[self.data['behavior_type'] == 'buy']['user_id'].count() # 由于收藏和加入购物车都为浏览和购买阶段之间确定购买意向的用户行为,且不分先后顺序,因此将其算作一个阶段 far_num = collect_num + cart_num trend_map = {'环节': ['pv', 'far', 'buy'], '人数': [pv_num, far_num, buy_num]} frame = pd.DataFrame(trend_map) # 计算单环节转化率 tmp1 = np.array(frame['人数'][1:]) tmp2 = np.array(frame['人数'][0:-1]) single_convs = list(tmp1 / tmp2) single_convs.insert(0, 1) # 在开始处插入1,因为pv阶段是没有转化率的 single_convs = [round(x, 4) for x in single_convs] frame['单一环节转化率'] = single_convs # 绘制漏斗图 attrs = frame['环节'].tolist() attr_values = (np.array(frame['单一环节转化率'] * 100).tolist()) funnel = Funnel("单一环节转化漏斗图", width=400, height=200, title_pos='center') funnel.add(name="商品交易行环节", # 指定图例名称 attr=attrs, # 指定属性名称 value=attr_values, # 指定属性所对应的值 is_label_show=True, # 指定标签是否显示 label_formatter='{c}%', # 指定标签显示的格式 label_pos="inside", # 指定标签的位置 legend_orient='vertical', # 指定图例的方向 legend_pos='left', # 指定图例的位置 is_legend_show=True) # 指定图例是否显示 funnel.render('render.html') # 生成html文件 # 总体转化率 tmp3 = np.array(frame['人数']) tmp4 = np.ones(len(frame['人数'])) * frame['人数'][0] # [942230. 942230. 942230.] total_convs = list(tmp3 / tmp4) total_convs = [round(x, 4) for x in total_convs] frame['总体转化率'] = total_convs # 绘制漏斗图 attrs = frame['环节'].tolist() attr_values = (np.array(frame['总体转化率'] * 100).tolist()) funnel1 = Funnel("总体转化漏斗图", width=400, height=200, title_pos='center') funnel1.add(name="商品交易行环节", # 指定图例名称 attr=attrs, # 指定属性名称 value=attr_values, # 指定属性所对应的值 is_label_show=True, # 指定标签是否显示 label_formatter='{c}%', # 指定标签显示的格式 label_pos="inside", # 指定标签的位置 legend_orient='vertical', # 指定图例的方向 legend_pos='left', # 指定图例的位置 is_legend_show=True) # 指定图例是否显示 funnel1.render('render1.html') # 生成html文件
visual_range=[0, 1000], maptype='china', symbol_size=8, effect_scale=5, is_visualmap=True) geo.render('大数据城市需求分布图.html') def get_experience(list): experience2 = {} for i in set(list): experience2[i] = list.count(i) return experience2 dir3 = get_experience(experience) #print(dir3) attr3 = dir3.keys() value3 = dir3.values() funnel = Funnel("工作经验漏斗图", title_pos='center') funnel.add("", attr3, value3, is_label_show=True, label_pos="inside", label_text_color="#fff", legend_orient='vertical', legend_pos='left') funnel.render('工作经验要求漏斗图.html')
# -*- coding: utf-8 -*- """ Created on Thu Aug 10 18:07:30 2017 @author: 17549 """ from pyecharts import Funnel attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20, 40, 60, 80, 100, 120] funnel = Funnel("动态漏图", width=600, height=400, title_pos='center') funnel.add("商品", attr, value, is_label_show=True, label_pos="outside", legend_orient='vertical', legend_pos='left') funnel.show_config() funnel.render(r"E:\12_动态漏图升级.html")
# v2=[listOA[0]] # radar =Radar() # radar.config(schema) # radar.add("全体信件总处理量", v1, is_splitline=True, is_axisline_show=True) # radar.add("校领导信箱处理量", v2, label_color=["#4e79a7"], is_area_show=False,is_label_show=True) # radar.show_config() # radar.render('radar.html') from pyecharts import Funnel attr = keyNameList value = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] for i in range(27): for j in range(9): value[i] += listOA[i][j] funnel = Funnel('各部门截止目前2017年处理总量金字塔', title_pos='center', width=1200, height=800) funnel.add('infomation', attr, value, is_label_show=True, label_pos="inside", label_text_color='#999', legend_orient='vertical', legend_pos='left') funnel.render('funnel.html')
plt.title('rebuy_user') print('多数用户复购次数:{}次'.format((date_rebuy-1).mode()[0])) plt.show()''' #(四)漏斗分析-流失率 data_user_count = data_user.groupby('behavior_type')['behavior_type'].count() pv_all = data_user['user_id'].count() print(data_user_count) print("总浏览量:",pv_all) print('总浏览量—点击量 流失率: {:.2f}'.format((pv_all-502835)/pv_all)) print("点击量-加入购物车量 流失率:{:.2f}".format((502835-10756)/502835)) print("加入购物车量-收藏量 流失率:{:.2f}".format((10756-14896)/10756)) print("收藏量-购买量 流失率:{:.2f}".format((14896-5195)/14896)) from pyecharts import Funnel funnel = Funnel("漏斗分析", width=600, height=400, title_pos='center') funnel.add("用户行为数据", ['点击','收藏','加入购物车','支付'],[502835,10756,14896,5195], is_label_show=True,label_formatter='{b} {c}',label_pos="outside",legend_orient='vertical', legend_pos='left') funnel.render('E:/python/data/user_behavior_analysis_tb/data.html') # (五)用户价值度分析 from datetime import datetime datenow = datetime(2014,12,20) # 计算每位用户最近购买时间 recent_buy_time = data_user[data_user.behavior_type==4].groupby('user_id')\ .date.apply(lambda x:datetime(2014,12,20)-x.sort_values().iloc[-1])\ .reset_index().rename(columns={'date':'recent'}) recent_buy_time.recent = recent_buy_time.recent.map(lambda x:x.days) # 计算每位用户消费频率 buy_freq = data_user[data_user.behavior_type==4].groupby('user_id').date.count().\ reset_index().rename(columns={'date':'freq'}) # 将最近购买时间和消费频率合并在一起
def draw_edu_funnel(data): funnel = Funnel("妹子学历分布漏斗图") funnel.add("学历", edu_interval, data, is_label_show=True, label_pos="inside", label_text_color="#fff", title_top=50) return funnel
from pyecharts import Funnel, Gauge, Graph attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] v1 = [5, 20, 36, 56, 78, 100] v2 = [55, 60, 16, 20, 15, 80] # 漏斗图 funnel = Funnel('漏斗图') funnel.add('商品', attr, v1, is_label_show=True, label_pos='inside', label_text_color="#fff") funnel.show_config() funnel.render(path="./data/02-01漏斗图.html") # 仪表盘 gauge = Gauge("仪表盘") gauge.add('业务指标', '完成率', 66.66) gauge.show_config() gauge.render(path="./data/02-02仪表盘.html") # 关系图 nodes = [{ "name": "结点1", "symbolSize": 10 }, { "name": "结点2", "symbolSize": 20 }, {
#! /usr/bin/env python from pyecharts import Funnel attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value = [20,40,60,80,100,120] funnel = Funnel('漏斗图示例', width = 600, height = 400, title_pos = "center") funnel.add("商品", attr, value, is_label_show = True, label_pos = "outside", legend_orient = "vertical", legend_pos = "left") funnel.render()
#encoding=utf-8 from pyecharts import Funnel attr =["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] value =[20, 40, 60, 80, 100, 120] funnel =Funnel("漏斗图示例") funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render()
Line3D.add("", data, is_visualmap=True) Line3D.render('E:\\pye\\line3d.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Gauge # 仪表盘 gauge = Gauge('项目完成进度') gauge.add('进度表', '完成率', 88.88) gauge.render('E:\\pye\\gauge.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Funnel # 漏斗图 attr = ['认知', '了解', '认可', '考虑', '意向', '购买'] value = [120, 100, 80, 60, 40, 20] funnel = Funnel('客户购买分析图') funnel.add('买车', attr, value, is_label_show=True, label_pos='inside', label_text_color='#fff') funnel.render('E:\\pye\\funel.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Liquid liquid = Liquid("水球图") liquid.add("Liquid", [0.8]) liquid.show_config() liquid.render('E:\\pye\\sq.html') # 在指定目录下生成文件
from pyecharts import Funnel #选项 attr = ["美女", '房子', '车子', '事业', '家人', '娱乐', '数码产品'] #权重 value = [150, 100, 80, 120, 140, 90, 70] #新建一个漏斗图 funnel = Funnel("男人心漏斗图") # 数据 权重 边缘标签 中间标签 funnel.add("因素", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render(r'C:\Users\Administrator\Desktop\数据可视化\pyecharts\html\8.html')
province, weight, visual_range=[0, 40000000], maptype='china', is_visualmap=True, visual_text_color='#000', is_label_show=True, is_piecewise=True, pieces=piece) map2.render("物料专配-省份分布.html") ##漏斗图 data_zhl = pd.read_excel(u"D:/code/Python/file/转化率作图.xlsx") attr = data_zhl.环节 values = data_zhl.总体转化率 funnel0 = Funnel('总体转化漏斗图', title_pos='center', width=2000, height=900) funnel0.add( name='环节', # 指定图例名称 attr=attr, # 指定属性名称 value=values, # 指定属性所对应的值 is_label_show=True, # 确认显示标签 label_formatter='{c}' + '%', # 指定标签显示的方式 legend_top='bottom', # 指定图例位置,为避免遮盖选择右下展示 # pyecharts包的文档中指出,当label_formatter='{d}'时,标签以百分比的形式显示. # 但我这样做的时候,发现显示的百分比与原始数据对应不上,只好用上面那种显示形式 label_pos='outside', # 指定标签的位置,inside,outside legend_orient='vertical', # 指定图例显示的方向 legend_pos='right') # 指定图例的位置 funnel0.render("转化漏斗.html")