示例#1
0
def plot_province(friends):
    friend_pro = []

    for each in friends[1:]:
        friend_pro.append(each['Province'])

    pr_loc = collections.Counter(friend_pro)
    print(pr_loc)
    value = []

    # map the counter value to pro_attr
    for each in pro_attr:
        value.append(pr_loc[each])

    print(value)
    friend_map = pc.Map(u'陈永斌 各省微信好友分布', 'John', width=1200, height=600)
    friend_map.add('',
                   pro_attr,
                   value,
                   maptype='china',
                   is_visualmap=True,
                   visual_text_color='#000')

    friend_map.show_config()
    friend_map.render('weixin1.html')
示例#2
0
def plot_oil_station_num_(re_dic, to_path):
    standard_province = ['安徽', '贵州', '澳门', '北京', '重庆', '福建', '福建', '甘肃', '广东', '广西', '广州', '海南', '河北', '黑龙江', '河南', '湖北', '湖南', '江苏',
           '江西', '吉林', '辽宁', '内蒙古', '宁夏', '青海', '山东', '上海', '陕西', '山西', '四川', '台湾', '天津', '香港', '新疆', '西藏', '云南', '浙江']
    dw = my_(config.MYSQL_BI_RW_ENV)
    muchcols_table = 'data_center.dc_stations_muchcols_enc'
    if re_dic['scale'] == 'china':
        sqls = "select province scale,count(*) numbers from %s where name like '%%%s%%' group by province order by numbers desc" % (muchcols_table, re_dic['name'])
        count_station_ = dw.to_dataframe(sqls)
        count_station_['scale'] = count_station_['scale'].apply(lambda x: change_city(x, standard_province))
    else:
        re_dic['scale'] = re_dic['scale'].split('省')[0]
        re_dic['scale'] = re_dic['scale'].split('市')[0]
        sqls = "select city scale,count(*) numbers from %s where province like '%%%s%%' and name like '%%%s%%' group by city order by numbers desc" % (muchcols_table, re_dic['scale'], re_dic['name'])
        count_station_ = dw.to_dataframe(sqls)

    num_Max = count_station_['numbers'].max()
    name_str = "油站名包含'%s':" %re_dic['name'] if re_dic['name'] else ''
    page = pyecharts.Page()
    style = pyecharts.Style(width=1300, height=860, background_color='#606a79', title_color="#eee", title_pos="center")
    map1 = pyecharts.Map(name_str+"油站分布地图", **style.init_style)
    map1.add("", count_station_['scale'], count_station_['numbers'], maptype=re_dic['scale'], visual_range=[0, num_Max], is_label_show=True,
               is_visualmap=True, visual_text_color='#eee')
    page.add(map1)
    chart2 = pyecharts.Bar(name_str+"油站分布柱状图", **style.init_style)
    chart2.add("", count_station_['scale'][:25], count_station_['numbers'][:25], maptype=re_dic['scale'], visual_range=[0, num_Max], is_label_show=True,
               is_visualmap=True, visual_text_color='#eee')
    page.add(chart2)
    page.render(to_path)
示例#3
0
def creat_WorldMap():
    value = [95.1, 23.2, 43.3, 66.4, 88.5]
    attr = ["China", "Canada", "Brazil", "Russia", "United States"]
    map = pyecharts.Map("世界地图", width=1200, height=600)
    map.add("", attr, value, maptype="world", is_visualmap=True,
            visual_text_color='#000')
    map.render('Map-World.html')
示例#4
0
def create_Map():
    a_city = []
    for i in cities:
        a_city.append(i + '市')
    map = pyecharts.Map("湖北最低气温", width=1200, height=600)
    map.add("最低气温", a_city, lows, maptype='湖北', is_visualmap=True, visual_text_color='#000', visual_range=[-15, 20])
    map.render("Map-low.html")
示例#5
0
def province_map(map_title, province_name, province_num):
    map_subtitle = '仅统计位于中国省份的信息'
    map = pyecharts.Map(title=map_title,
                        subtitle=map_subtitle,
                        width=1600,
                        height=800)
    # print(map.width)
    map.add('',
            province_name,
            province_num,
            maptype='china',
            is_visualmap=True)
    map_file_name = './' + map_title + '.html'
    try:
        map.render(path=map_file_name)
        print('%s已保存至%s' % (map_title, map_file_name))
    except Exception as e:
        logging.debug(u'Error:%s' % e)
        pass
    def areas_price_distribution(self):

        temp = self.data.groupby(['area_positon'
                                  ])['unit-price'].mean().reset_index()
        temp = temp.round(1)
        attr = list(temp['area_positon'])
        value = list(temp['unit-price'])

        map = pyecharts.Map("深圳各行政区二手房均价",
                            "统计时间:2018-09-22",
                            width=800,
                            height=600)
        map.add("二手房均价(单位:万元)",
                attr,
                value,
                maptype=u"深圳",
                is_legend_show=False,
                is_label_show=True,
                is_visualmap=True,
                visual_text_color="#000",
                visual_range=[3, 8])
        map.render()
示例#7
0
                                    as_index=False)['single_price'].mean()
grouped_single_price.sort_values(by='single_price', ascending=False)

attr = list(grouped_single_price['areaName'])
vv = grouped_single_price['single_price'] * 10000
value = list(vv.round(2))
print(type(grouped_single_price['single_price']))
#行政区的名称与map 中的保持一致
for i, dist in enumerate(attr):
    if (dist.find('区') == -1):
        attr[i] = attr[i] + '区'

print(attr)
print(value)
print(type(attr))
map = pyecharts.Map("沈阳各行政区二手房均价", "统计时间:2019-04-25", width=800, height=1600)
map.add(
    "二手房均价(单位:元)",
    attr,
    value,
    maptype=u"沈阳",
    is_legend_show=True,
    is_label_show=True,
    visual_range=[min(value), max(value)],
    is_visualmap=True,
)
map
#map.render("沈阳各行政区二手房均价.html")

# In[53]: