def analysisArea(self): title = '微信好友国内分布' data = {'保密': 0} map_ = Map(title, width=1200, height=600) map_.use_theme('purple-passion') for each in self.friends_info.get('province'): if not each: data['保密'] += 1 else: if each in data: data[each] += 1 else: data[each] = 1 attrs = [i for i, j in data.items()] values = [j for i, j in data.items()] map_.add('', attrs, values, maptype='china', is_visualmap=True, visual_text_color='#000') map_.render(os.path.join(self.savedir, '%s.html' % title))
def analysisAreaInGD(self): title = '微信好友广东省内分布' data = {'保密': 0} map = Map(title, width=1200, height=600) map.use_theme('purple-passion') for each in self.friends_info.get('city'): if not each: data['保密'] += 1 else: if each in data: data[each] += 1 else: data[each] = 1 attrs = [i for i, j in data.items()] values = [j for i, j in data.items()] for i in range(len(attrs)): str = attrs[i] attrs[i] = str + "市" map.add('', attrs, values, maptype='广东', is_visualmap=True, visual_text_color='#000') map.render(os.path.join(self.savedir, '%s.html' % title))
df["pro"] = df.area.apply(getProvince) # df=df.dropna(axis = 0) pro_count = df.groupby("pro")["nick"].count().sort_values(ascending=False) bar = Bar("省份分布") # bar.use_theme("macarons") #换主题 bar.add("省份", pro_count.index, pro_count.values, is_label_show=True, xaxis_interval=0, xaxis_rotate=-45) bar.render("评论的省份分布柱状图.html") mapp = Map("省份分布", width=1000, height=600) mapp.use_theme("macarons") mapp.add("评论数", pro_count.index, pro_count.values, maptype="china", is_visualmap=True, visual_range=[pro_count.values.min(), pro_count.values.max()], is_map_symbol_show=False, visual_text_color="#000", is_label_show=True) mapp.render("评论的省份分布地图.html") def getCity(area, pro): res = area.replace(pro, "")
"西藏", "新疆", "云南", "浙江", ] # background_color ='#293C55' # width=1200, height=600 # renderer='svg' map = Map("中国充电站数目分布图", subtitle='数据来源于北汽新能源', width=1400, height=700, title_pos='center') # map = Map("Map 结合 VisualMap 示例", width=1200, height=600) map.use_theme('chalk') map.add( "", attr, value, visual_range=[0, 3131], visual_text_color="#FFFFFF", maptype="china", is_visualmap=True, visual_pos='73%', visual_top='38%', # visual_text_color="#000", legend_pos='center', ) map.render("中国充电站分布.png")