コード例 #1
0
ファイル: river.py プロジェクト: liangsqrt/PowerShare
def plot_inflow_of_all_main_river(title="四川当月水库蓄水量信息.html",
                                  day_delta=30,
                                  path="source"):
    """
    绘制四川当月所有河流的蓄水量信息。
    :param title:
    :return:
    """
    engine = init_engine(db="power_supply")

    datetime_now = datetime.datetime.now()
    last_month = (
        datetime_now -
        datetime.timedelta(days=day_delta)).strftime("%Y-%m-%d 00:00:00")
    df1 = pd.read_sql(
        "SELECT * FROM sc_main_river_storage WHERE official_update_time> '{last_month}'"
        .format(last_month=last_month), engine)

    line2 = Line("全流域蓄水量", width="1600px", height="800px")
    df1_1 = df1.groupby(axis=0,
                        by=["official_update_time"
                            ]).aggregate({"water_storage_capacity": "sum"})
    df1_2 = df1_1.reset_index()
    line2.add(
        "全流域河流蓄水量图",
        df1_2["official_update_time"].map(lambda x: x.strftime("%Y-%m-%d")),
        df1_2["water_storage_capacity"])

    line2.render(title)
コード例 #2
0
ファイル: matplot.py プロジェクト: Cris0525/StudyNotes
def chart(lists):
    bar = Line("学生成绩平均绩点折线图")
    bar.add(
        "平均绩点GPA", ["大一(上)", "大一(下)", "大二(上)", "大二(下)", "大三(上)", "大三(下)"],
        [lists[0], lists[1], lists[2], lists[3], lists[4], lists[5], lists[6]],
        is_more_utils=True)
    bar.show_config()
    bar.render()
    #shutil.move('/home/cris/system/flask/render.html','/home/cris/system/flask/templates/html')

    with open('/home/cris/system/flask/render.html', 'r') as f:
        hello = f.read()
        abc = hello

    with open('/home/cris/system/flask/templates/student.html', 'w') as f1:
        f1.write("{% extends 'base.html' %}")
        f1.write('\n')
        f1.write("{% block page_name %}你好,{{login_user}}{% endblock %}")
        f1.write('\n')
        f1.write("{% block body_part1 %}你好,{{login_user}}{% endblock %}")
        f1.write('\n')
        f1.write("{% block body_part2 %}")
        f1.write('\n')
        f1.write(abc)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #3
0
ファイル: test_line.py プロジェクト: wei1476160943/pyecharts
def test_line_type():
    # line is_stack
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", attr, v1, is_stack=True, is_label_show=True)
    line.add("商家B", attr, v2, is_stack=True, is_label_show=True)
    line.render()

    # line is_step
    line = Line("折线图-阶梯图示例")
    line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    assert '"step": true' in line._repr_html_()

    # line is_fill
    line = Line("折线图-面积图示例")
    line.add("商家A", attr, v1, is_fill=True, line_opacity=0.2,
             area_opacity=0.4, symbol=None)
    line.add("商家B", attr, v2, is_fill=True, area_color='#000',
             area_opacity=0.3, is_smooth=True)
    assert '"step": true' not in line._repr_html_()

    # line yAxis type 'log'
    import math
    import random
    line = Line("折线图示例")
    line.add("商家A", attr,
             [math.log10(random.randint(1, 99999)) for _ in range(6)])
    line.add("商家B", attr,
             [math.log10(random.randint(1, 99999999)) for _ in range(6)],
             yaxis_type="log")
    line.render()
コード例 #4
0
def showJson(data):
    attr = []
    v1 = []  # 鱼类养殖面积
    v2 = []  # 海水养殖面积
    print(data[0]['省(市)名称'])
    for i in range(len(data)):
        print(data[i])
        attr.append(data[i]['采集年份'])
        v1.append(data[i]['鱼类养殖面积'])
        v2.append(data[i]['海水养殖面积'])
        for j in data[i]:
            print('-------------------' + j)
        print(attr)
    line = Line("折线图-面积图示例")
    line.add("商家A",
             attr,
             v1,
             is_fill=True,
             line_opacity=0.2,
             area_opacity=0.4,
             symbol=None)
    line.add("商家B",
             attr,
             v2,
             is_fill=True,
             area_color='#000',
             area_opacity=0.3,
             is_smooth=True)
    # line.show_config()
    line.render()
コード例 #5
0
ファイル: image_case.py プロジェクト: P79N6A/python_learning
def mutual_info_ex(param):
    params = common.parse_param(param)
    path_a = params[0]
    ids = []
    mis = []
    for i in range(5):
        mis.append([])
    j = 0
    for path in params:
        res = _mutual_info_ex(path, path_a)
        if j != 0:
            ids.append(j)
            for i in range(5):
                mis[i].append(res[i])
        pprint(res)
        j = j + 1
    bar = Line("我的第一个图表", "这里是副标题")
    num_mis = len(mis)
    for index in range(num_mis):
        num_ele = len(mis[index])
        max_n = max(mis[index])
        for ele_i in range(num_ele):
            mis[index][ele_i] = mis[index][ele_i] / max_n

    for i in range(5):
        bar.add("mi" + str(i), ids, mis[i], is_more_utils=True)
    bar.render()
    pprint(mis)
    return
コード例 #6
0
def generate(df, flg, stockCode, stockName, is_gen_single):
    Y_AXIS_NAMES = ['收盘价', '温度']
    if flg is 'stock_A':
        Y_AXIS_NAMES = ['前复权', '温度']
    dates = df['date']
    y_axises2 = []
    y_axises2.append(df['absolute_temp'])
    y_axises2.append(df['relative_temp'])
    decimal = 3
    y_axises2.append(df['avg_temp'].round(decimals=decimal))
    y_axises2.append(df['pb'].round(decimals=decimal))
    y_axises2.append(df['pe'].round(decimals=decimal))
    y_axises2.append(df['roe'].round(decimals=decimal))
    y_axises2.append(df['s'].round(decimals=decimal))
    y_axises2.append(df['guozhai'].round(decimals=decimal))
    y_axises = df["cp"]

    line = Line(width=1200, title=stockName)
    option = option_process(stockCode, stockName, CHART_NAMES, dates, y_axises,
                            y_axises2, Y_AXIS_NAMES)

    # line.render('output/temp_line.html')
    # line._option = getOption()
    file = 'output/abs_temp_line_' + flg + '_' + stockCode + '.html'
    line._option = option
    if is_gen_single is True:
        line.render(path=file,
                    template_name='template/temp_history.html',
                    object_name='line')
    return line
コード例 #7
0
ファイル: article_analysis.py プロジェクト: wwxs972/article
def create_month(df):
    """
    生成月份分布情况(总的)
    """
    month_message = df.groupby(['month'])
    month_com = month_message['month'].agg(['count'])
    month_com.reset_index(inplace=True)
    # 生成折线图
    attr = ["{}".format(str(i) + '月') for i in month_com['month']]
    v1 = month_com['count']
    line = Line("公众号文章月份发布数量走势图",
                title_pos='center',
                title_top='18',
                width=800,
                height=400)
    line.add("",
             attr,
             v1,
             xaxis_interval=0,
             yaxis_max=120,
             is_smooth=True,
             is_fill=True,
             area_color="#000",
             is_xaxislabel_align=True,
             xaxis_min="dataMin",
             area_opacity=0.3,
             mark_point=["max"],
             mark_point_symbol="pin",
             mark_point_symbolsize=45)
    line.render("公众号文章月份发布数量走势图.html")
コード例 #8
0
def new_user_year_all():
    result_2015 = get_user_month_line_data_of_year(2015)
    result_2016 = get_user_month_line_data_of_year(2016)
    result_2017 = get_user_month_line_data_of_year(2017)
    result_2018 = get_user_month_line_data_of_year(2018)

    line = Line("新增用户趋势")
    line.add('2015新增用户趋势',
             result_2015[0],
             result_2015[1],
             mark_line=["average"],
             is_smooth=True,
             mark_point=["max", "min"])
    line.add('2016新增用户趋势',
             result_2016[0],
             result_2016[1],
             mark_line=["average"],
             is_smooth=True,
             mark_point=["max", "min"])
    line.add('2017新增用户趋势',
             result_2017[0],
             result_2017[1],
             mark_line=["average"],
             is_smooth=True,
             mark_point=["max", "min"])
    line.add('2018新增用户趋势',
             result_2018[0],
             result_2018[1],
             mark_line=["average"],
             is_smooth=True,
             mark_point=["max", "min"])
    # bar.show_config()
    fileName = 'user_join_data.html'
    line.render(fileName)
    return send_file(fileName)
コード例 #9
0
ファイル: wifi_probe_analysis.py プロジェクト: wkhola/hft
    def passenger_flow(self, store_id):
        """
        统计店铺的客流量
        :return:
        """
        self.store_id = store_id
        df = pd.read_csv("./daily/2018-05-17.csv",
                         index_col=False,
                         delimiter=',')
        df_time = to_datetime(df.time, format='%Y/%m/%d')  # 时间格式化

        # 所有店铺的客流量
        count = len(
            df.drop_duplicates(subset=['mac'], keep='first', inplace=False))

        # 店铺一天的客流量
        count_day = df.groupby('shop_id').agg({
            'shop_id': 'max',
            'mac': pd.Series.nunique
        })

        # 按小时计算店铺的客流量
        count_hour = df[df['shop_id'] == store_id].groupby(['shop_id', df_time.dt.hour]) \
            .agg({'mac': pd.Series.nunique, 'time': 'min'}) \
            # .sort_values(['shop_id', 'mac'], ascending=[True, False])

        t = count_hour.time
        count = count_hour.mac
        from pyecharts import Bar, Line
        ts = [str(_).split(':')[0].split('2018-')[1] for _ in t]
        print count_hour
        bar = Line(width="100%")
        bar.add("店铺客流量", ts, count, is_datazoom_show=True, is_label_show=True)

        bar.render(u"客流量.html")
コード例 #10
0
def chart(credit_list, time_list):
    bar = Line("学生成绩平均绩点折线图\n")
    bar.add("平均绩点GPA", time_list, credit_list, is_more_utils=True)
    bar.show_config()
    bar.render()
    shutil.move('/home/fty/new-system/render.html',
                '/home/fty/new-system/templates/student.html')

    file = ""
    with open('/home/fty/new-system/templates/student.html', 'r') as f:
        hello = f.read()
        file = hello
        f.close()

    head = '''
    {% extends 'base.html' %}
    {% block page_name %}你好,{{login_user}}{% endblock %}
    {% block body_part3 %}
    <a href="{{ url_for('student') }}" class="nav-link active">
    {% endblock %}
    {% block body_part1 %}
    <span class="glyphicon glyphicon-stats"></span>&ensp;你好,{{login_user}}
    {% endblock %}
    {% block body_part2 %}
    '''
    with open('/home/fty/new-system/templates/student.html', 'w') as f1:
        f1.write(head)
        f1.write(file)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #11
0
def statistics_for_op_length():
    '''
    本函数用以确定下面函数中的support的值
    fc: 非流失玩家最大动作序列长度20219 最小序列长度1, 流失玩家最大序列长度7323 ,最小序列长度 1
    选取的最小支持度是16,此时剔除掉了非流失玩家用户193 流失玩家用户1497
    '''
    from pyecharts import Line
    fc_user_ops, fc_user_label, sc_user_ops, sc_user_label, tc_user_ops, tc_user_label, action_id = get_op_features_labels_from_pickle(
    )
    ops_length = [[], []]
    [
        ops_length[fc_user_label[user]].append(len(ops))
        for user, ops in fc_user_ops.items()
    ]

    user_length = [[], []]
    c = [0, 0]
    temp = [list(np.sort(ops_length[0])), list(np.sort(ops_length[1]))]
    for support in range(1, max(ops_length[1])):
        # 在1 和 max ops_length[1] 之间集中了大部分的游戏玩家
        for i in [0, 1]:
            for t in temp[i][c[i]:]:
                if t <= support:
                    c[i] += 1
            user_length[i].append(c[i])

    line = Line()
    index = [i for i in range(0, 100)]
    line.add("非流失玩家", index, user_length[0][:100])
    line.add("流失玩家", index, user_length[1][:100])
    line.show_config()
    line.render()
コード例 #12
0
    def draw_city_aqi(self, time = None):
        #from opendatatools import aqi
        line = Line("长沙当日AQI",
                         width=425,
                         height=730)
        data_dict = {}
        city=local
        print("getting data for %s" % city)
        #df_aqi = aqi.get_daily_aqi_onecity(city)
        aqi_hour=pd.read_csv('daylocal.csv')
    
            #print(df_aqi)
            #print(aqi_hour)
        aqi_hour.set_index('time', inplace=True)
        aqi_hour.sort_index(ascending=True, inplace=True)
        if time is not None:
            aqi_hour = aqi_hour[aqi_hour.index <= time]
            
        data_dict[city] = aqi_hour
        axis_x = aqi_hour.index
        axis_y = aqi_hour['aqi']
        line.add("%s" % (city), axis_x, axis_y, mark_point=["max","min"])
        line.render('aqi.html')
        #return line

        self.webView.load(QUrl("file:///D:/源代码/aqi.html"))

       # self.webView.reload()
        self.webView.repaint()
        self.webView.update()
コード例 #13
0
ファイル: movie.py プロジェクト: z991/python_mianshi_self
    def xing_jia_bi(self):
        """
        获取性价比电影
        :return:
        """
        res = self.get_data()
        test = res.drop_duplicates(subset=['name'], keep="first")
        # 根据口碑指数排名top10
        sort_wom_index = test.sort_values(by="wom_index", ascending=False)[0:11]
        # 对上面根据价格进行排序
        sort_price = sort_wom_index.sort_values(by="avg_price", ascending=True)
        sort_price.to_csv("wom_price11.csv")

        movie_list = []
        price_list = []
        wom_list = []
        # 读取csv文件
        csv_file = csv.reader(open('wom_price11.csv', 'r'))
        # 生成echarts表
        for wp in csv_file:
            if wp[1] == "date":
                continue
            movie_list.append(wp[2])
            price_list.append(wp[4])
            wom_list.append(wp[8])
        line = Line("性价比(价格/口碑指数)")
        line.add("平均价格价格", movie_list, price_list)
        line.add("口碑指数", movie_list, wom_list)
        line.render(path="性价比111.html", )
コード例 #14
0
ファイル: matplot.py プロジェクト: Cris0525/StudyNotes
def chart(lists):
    bar = Line("学生成绩平均绩点折线图")
    bar.add("平均绩点GPA", ["大一(上)", "大一(下)", "大二(上)", "大二(下)", "大三(上)", "大三(下)"],
            [lists[0], lists[1], lists[2], lists[3], lists[4], lists[5]],
            is_more_utils=True)
    bar.show_config()
    bar.render()
    shutil.move('/home/cris/new_system/render.html',
                '/home/cris/new_system/templates/student.html')

    file = ""
    with open('/home/cris/new_system/templates/student.html', 'r') as f:
        hello = f.read()
        file = hello
        f.close()

    head = '''
    {% extends 'base.html' %}
    {% block page_name %}你好,{{login_user}}{% endblock %}
    {% block body_part3 %}
    <a href="{{ url_for('student') }}" class="nav-link active">
    {% endblock %}
    {% block body_part1 %}
    <span class="glyphicon glyphicon-stats"></span>&ensp;你好,{{login_user}}
    {% endblock %}
    {% block body_part2 %}
    '''
    with open('/home/cris/new_system/templates/student.html', 'w') as f1:
        f1.write(head)
        f1.write(file)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #15
0
def show_date(global_set):
    db = global_set.db
    cursor = global_set.cursor
    # 使用execute方法执行SQL语句
    sql = """SELECT date_of_view, COUNT(ID) FROM remarks GROUP BY date_of_view ASC;"""
    try:
        cursor.execute(sql)
    except:
        print('数据读取失败!')
        db.rollback()
    dates_data = cursor.fetchall()
    #  获取各星级评价人数
    date_list = []
    date_num_list = []
    for key_name, key_value in dates_data:
        date_list.append(key_name)
        date_num_list.append(key_value)
    print(date_list)
    print(date_num_list)
    #  配置折线图参数
    attr = date_list
    v1 = date_num_list
    line = Line(global_set.show_title, global_set.show_subtitle_2)
    line.add("观看时间分布",
             attr,
             v1,
             is_fill=True,
             area_color='#000',
             area_opacity=0.3,
             mark_point=["max"],
             is_smooth=True,
             mark_line=["max", "average"])
    line.render(global_set.save_path_2)
コード例 #16
0
def bir():
    print("生成js源码中……")
    line = Line("{}".format(bir_name()))
    line.add("{}".format(bir_quadrant_1()),
             irs_a_name,
             irs_a,
             is_fill=True,
             area_color='EED5B7',
             area_opacity=0.4,
             is_smooth=True)
    line.add("{}".format(bir_quadrant_2()),
             irs_b_name,
             irs_b,
             is_fill=True,
             area_color='#1C86EE',
             area_opacity=0.3,
             is_smooth=True)
    line.add("{}".format(bir_quadrant_3()),
             irs_c_name,
             irs_c, is_fill=True,
             area_color='#FF0000',
             area_opacity=0.5,
             is_smooth=True,
             is_more_utils=True)
    line_name = input("存放图表的文件名:")
    line.render("{}.html".format(line_name))
    print("js源码生成完毕……\n")
コード例 #17
0
ファイル: pricemonitor.py プロジェクト: louis-cai/Xrypto
    def render_to_html(self):
        import pandas as pd
        from pyecharts import Line

        df = pd.read_csv(self.out_dir + self.ok_f)

        attr = [i[1] for i in df.values]
        p1 = [i[2] for i in df.values]
        p2 = [i[3] for i in df.values]
        d3 = [i[4] for i in df.values]

        line = Line("统计套利")
        line.add("价差",
                 attr,
                 d3,
                 is_smooth=True,
                 mark_point=["max", "average", "min"],
                 mark_line=["max", "average", "min"])
        # line.add("外盘内盘价差", attr2, v2, is_smooth=True, mark_line=["max", "average"])
        line.render('./data/index.html')

        line = Line("统计套利")
        line.add("ok", attr, p1)
        line.add("ok季度", attr, p2)
        line.render('./data/index2.html')
コード例 #18
0
ファイル: article_analysis.py プロジェクト: wwxs972/article
def create_month_year(df):
    """
    生成每年各月份分布情况
    """
    v = []
    # 生成每年的月份情况
    for i in ['2014', '2015', '2016', '2017', '2018']:
        dom = df[df['year'] == i]
        dom_message = dom.groupby(['month'])
        dom_com = dom_message['month'].agg(['count'])
        dom_com.reset_index(inplace=True)
        v1 = np.array(dom_com['count'])
        v1 = ["{}".format(int(i)) for i in v1]
        attr = dom_com['month']
        v.append(v1)

    # 生成折线图
    attr = ["{}".format(str(i) + '月') for i in attr]
    line = Line("公众号文章每年各月份发布数量走势图",
                title_pos='center',
                title_top='0',
                width=800,
                height=400)
    line.add("2015", attr, v[1], line_color='red', legend_top='8%')
    line.add("2016", attr, v[2], line_color='purple', legend_top='8%')
    line.add("2017", attr, v[3], line_color='green', legend_top='8%')
    line.add("2018", attr, v[4], line_color='orange', legend_top='8%')
    line.render("公众号文章每年各月份发布数量走势图.html")
コード例 #19
0
def time_qushi(graph_title):
    result = None
    attr = [
        '6月19', '6月20', '6月21', '6月22', '6月23', '6月24', '6月25', '6月26', '6月27',
        '6月28'
    ]
    data = []
    # pipe = [
    #     {'$sort': {'publish_time': -1},'allowDiskUse':True },
    #     {'$limit': 10}
    # ]
    # 1530085564
    for i in range(10):
        pipe = [{
            '$match': {
                'publish_time': {
                    '$lte': 1530085564 - i * 24 * 60 * 60,
                    '$gt': 1530085564 - (i + 1) * 24 * 60 * 60
                }
            }
        }]
        data.append(len(list(coll.aggregate(pipe))))

    # from pyecharts import Line

    line = Line(graph_title)
    line.add("",
             attr,
             data,
             iis_stack=True,
             is_label_show=True,
             width=1200,
             height=600)
    line.render('./' + graph_title + '.html')
コード例 #20
0
ファイル: lineChart.py プロジェクト: ssk-cms/ZfbRecharge1
    def StationLine(self, data):
        attr2 = []
        v2 = []
        total2 = 0
        for row in data:
            hour = row[0]
            minute = row[1]
            count = row[2]

            total2 += count
            if hour == None and minute == None:
                attr2.append("无时间")
            else:
                attr2.append(hour + ":" + minute)
            v2.append(count)

        line = Line("全部数据分时间段换电站内进入车辆信息统计",
                    "车辆总数为" + str(total2),
                    width=1500,
                    height=600)
        line.add("全部数据分时间段进入换电站车辆数量",
                 attr2,
                 v2,
                 mark_line=["max", "average", "min"])
        line.render(path="./GUI/全部数据每隔半小时进入换电站车辆信息统计.html")
コード例 #21
0
def length_distance(path_name):
    sharp_ratio = []
    pnl_ratio = []
    max_dd = []
    name_list = []

    file_list = os.listdir(path_name)
    for file_name in file_list:
        with open(path_name + file_name, 'r', encoding='utf-8') as json_file:
            date_dict = json.loads(json_file.read())

        sharp_ratio.append(date_dict["sharp_ratio"])
        pnl_ratio.append(date_dict["pnl_ratio"])
        max_dd.append(date_dict["max_drawdown"])

        file = file_name.replace('.json', '')
        name_list.append(file[:2] + '_' + file[3:].replace('_', '.'))

    line = Line("Bollinger Band 3")
    line.add("sharp_ratio", name_list, sharp_ratio, mark_point=["max"])
    line.add("pnl_ratio", name_list, [item for item in pnl_ratio])
    line.add("max_dd*10",
             name_list, [item * 10 for item in max_dd],
             xaxis_name="length-distance",
             xaxis_rotate=90,
             xaxis_interval=0,
             xaxis_name_pos="end")
    line.render("Bollinger Band 3.html")
コード例 #22
0
def nav_line(path_name, figure_name):

    with open(path_name, 'r', encoding='utf-8') as json_file:
        temp_dict = json.loads(json_file.read())

    nav_list = []
    high_level = []
    time_list = []
    for date in range(len(temp_dict["indicatorDuration"])):
        nav_list.append(temp_dict["indicatorDuration"][date]["nav"])
        time_list.append(
            temp_dict["indicatorDuration"][date]["createdAt"][:10])
        if len(high_level) < 1:
            high_level.append(nav_list[-1])
        else:
            high_level.append(max(nav_list[-1], high_level[-1]))

    line = Line(figure_name)
    line.add("净值线", time_list, nav_list)
    line.add("高水平线",
             time_list,
             high_level,
             xaxis_name="Time",
             xaxis_rotate=30,
             xaxis_interval=30,
             xaxis_name_pos="end",
             yaxis_min=1000000)
    line.render(figure_name + ".html")
コード例 #23
0
ファイル: analysis_data.py プロジェクト: ztlgc/spider
def time_num_visualization(time):
    from pyecharts import Line
    time_list = list(set(time))
    time_dict = {time_list[i]: 0 for i in range(len(time_list))}
    time_num = []
    for i in range(len(time_list)):
        time_dict[time_list[i]] = time.count(time_list[i])
    # 根据数量(字典的键值)排序
    sort_dict = sorted(time_dict.items(), key=lambda d: d[0], reverse=False)
    time_name = []
    time_num = []
    print(sort_dict)
    for i in range(len(sort_dict)):
        time_name.append(sort_dict[i][0])
        time_num.append(sort_dict[i][1])

    line = Line("评论数量日期折线图")
    line.add(
        "日期-评论数",
        time_name,
        time_num,
        is_fill=True,
        area_color="#000",
        area_opacity=0.3,
        is_smooth=True,
    )
    line.render("H:\PyCoding\spider_maoyan\picture\c_num_line.html")
コード例 #24
0
ファイル: balancedumper.py プロジェクト: zhuyk/Xrypto
    def render_to_html(self):
        import pandas as pd
        from pyecharts import Line

        df = pd.read_csv(self.out_dir + self.asset_csv)

        attr = [i[1] for i in df.values]
        price = [i[2] for i in df.values]
        btc = [i[3] for i in df.values]
        bch = [i[4] for i in df.values]
        profit = [i[5] for i in df.values]

        line = Line("利润曲线")
        line.add("profit",
                 attr,
                 profit,
                 is_smooth=True,
                 mark_point=["max", "average", "min"],
                 mark_line=["max", "average", "min"])
        # line.add("外盘内盘价差", attr2, v2, is_smooth=True, mark_line=["max", "average"])
        line.render('./data/kp.html')

        line = Line("资产统计")
        line.add("btc", attr, btc)
        line.add("bch", attr, bch)
        line.render('./data/ka.html')
コード例 #25
0
ファイル: create_htm.py プロジェクト: lichen404/weatherSpider
def create_temp_htm(city):
    client = MongoClient('localhost', 27017)
    db = client['tianqihoubao']
    data = db[city]
    max_temp_list = []
    min_temp_list = []
    day_list = []
    results = data.find({}).sort([("date", 1)])
    for d in results:
        max_temp_list.append(d['max_temp'])
        min_temp_list.append(d['min_temp'])
        day_list.append(d['date'])
    city_name = get_city_name(city)
    line = Line(city_name + "2011年至今气温变化", page_title="气温变化表")
    line.add(
        "最高温度",
        day_list,
        max_temp_list,
        mark_point=["max", "min"],
        mark_line=["average"],
    )
    line.add(
        "最低温度",
        day_list,
        min_temp_list,
        mark_point=["max", "min"],
        mark_line=["average"],
        yaxis_formatter="°C",
    )
    line.render(city_name + '气温变化表.html')
コード例 #26
0
ファイル: gen_report.py プロジェクト: aceforeverd/HybridSE
def generate_trend(benchmarks_map, columns, cate):
    lines = {}
    max_cnt = len(columns)
    for (group, benchmarks) in benchmarks_map.items():
        print(benchmarks)

        print(benchmarks.keys())
        for (bm_name, benchmark) in benchmarks.items():
            print(bm_name)
            #is_label_show是设置上方数据是否显示
            print(benchmark[cate])
            html_name = group + "_" + bm_name.split("/")[0]
            if not html_name in lines:
                line = Line("性能" + cate + "趋势",
                            "性能" + cate + "趋势",
                            width=1600,
                            height=1000)
                lines[html_name] = line

            line = lines[html_name]
            line.add(bm_name,
                     columns,
                     benchmark[cate][0:max_cnt],
                     is_label_show=True)
    for (name, line) in lines.items():
        render_name = "./render/" + cate + "Trend_" + name + ".html"
        print(render_name)
        line.render(render_name)
コード例 #27
0
def echarts_plot(html_path, html2_path, col_1, row_1, col_2, row_2):
    '''绘图1'''
    line = Line("近十日标注量变化曲线",
                datetime.datetime.now().strftime('%Y-%m-%d'),
                width=1200,
                height=600)
    line.add("日期",
             row_1,
             col_1,
             mark_point=["max", "min"],
             mark_line=["average"],
             is_datazoom_show=False,
             is_symbol_show=True)
    line.render(path=html_path, pixel_ratio=3)
    '''绘图完成'''
    '''绘图2'''
    line = Line("近十日审核量变化曲线",
                datetime.datetime.now().strftime('%Y-%m-%d'),
                width=1200,
                height=600)
    line.add("日期",
             row_2,
             col_2,
             mark_point=["max", "min"],
             mark_line=["average"],
             is_datazoom_show=False,
             is_symbol_show=True)
    line.render(path=html2_path, pixel_ratio=3)
    '''绘图完成'''
コード例 #28
0
ファイル: pricemonitor.py プロジェクト: louis-cai/Xrypto
    def render_to_html_cross(self):
        import pandas as pd
        from pyecharts import Line

        # df = pd.read_csv('./data/diff.csv')
        df = pd.read_csv(self.out_dir + self.b_f)

        attr = [i[1] for i in df.values]
        p1 = [i[2] for i in df.values]
        p2 = [i[3] for i in df.values]
        d3 = [i[4] for i in df.values]

        line = Line("统计套利")
        line.add("价差",
                 attr,
                 d3,
                 is_smooth=True,
                 mark_point=["max", "average", "min"],
                 mark_line=["max", "average", "min"])
        line.render('./data/c.html')

        line = Line("统计套利")
        line.add("ok", attr, p1)
        line.add("bitfinex", attr, p2)
        line.render('./data/c2.html')
コード例 #29
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_negative_value():
    line = Line("折线图示例")
    line.add("最高气温", WEEK, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", WEEK, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"], mark_line=["average"])
    line.render()
コード例 #30
0
def show(path):
    d=os.listdir(path)
    d_len=[len(os.listdir(os.path.join(path,i))) for i in d]

    line = Line()
    line.add("train", d, d_len, mark_point=["average", "max", "min"],xaxis_rotate=40, )
    line.render(path="temp.html")
コード例 #31
0
def line_test(b, num):
    X = pd.Series(unique(b)).values
    Y = pd.Series(num.groupby(b).sum()).values
    line = Line("香飘飘2019/04到2019/05月各省区经销商分销量")
    line.add("", X, Y, mark_point=["average"])
    line.show_config()
    line.render("E:\\py_data_html\\line_test.html")
コード例 #32
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_user_define_markpoint():
    line = Line("折线图示例")
    line.add("商家A", CLOTHES, clothes_v1,
             mark_point=["average", {
                 "coord": ["裤子", 10], "name": "这是我想要的第一个标记点"}])
    line.add("商家B", CLOTHES, clothes_v2, is_smooth=True,
             mark_point=[{
                 "coord": ["袜子", 80], "name": "这是我想要的第二个标记点"}])
    line.render()
コード例 #33
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_log_yaxis():
    import math
    import random
    line = Line("折线图示例")
    line.add("商家A", CLOTHES,
             [math.log10(random.randint(1, 99999)) for _ in range(6)])
    line.add("商家B", CLOTHES,
             [math.log10(random.randint(1, 99999999)) for _ in range(6)],
             yaxis_type="log")
    line.render()
コード例 #34
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_user_define_marks():
    line = Line("折线图示例")
    line.add("商家A", CLOTHES, clothes_v1,
             mark_point=["average", "max", "min"],
             mark_point_symbol='diamond', mark_point_textcolor='#40ff27')
    line.add("商家B", CLOTHES, clothes_v2,
             mark_point=["average", "max", "min"],
             mark_point_symbol='arrow', mark_point_symbolsize=40)
    line.show_config()
    line.render()
コード例 #35
0
def draw_sentiment_pic(csv_file):
    attr, val = [], []
    info = count_sentiment(csv_file)
    info = sorted(info.items(), key=lambda x: x[0], reverse=False)  # dict的排序方法
    for each in info[:-1]:
        attr.append(each[0])
        val.append(each[1])
    line = Line(csv_file+":影评情感分析")
    line.add("", attr, val, is_smooth=True, is_more_utils=True)
    line.render(csv_file+"_情感分析曲线图.html")
コード例 #36
0
ファイル: test_line.py プロジェクト: Jesszen/pyecharts
def test_line_marks():
    line = Line("折线图示例")
    line.add("商家A", CLOTHES, clothes_v1, mark_point=["average"])
    line.add(
        "商家B",
        CLOTHES,
        clothes_v2,
        is_smooth=True,
        mark_line=["max", "average"],
    )
    line.render()
コード例 #37
0
ファイル: test_line.py プロジェクト: ljwdoc/pyecharts
def test_line():

    # line_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()

    # line_0_1
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average", "max", "min"],
             mark_point_symbol='diamond', mark_point_textcolor='#40ff27')
    line.add("商家B", attr, v2, mark_point=["average", "max", "min"],
             mark_point_symbol='arrow', mark_point_symbolsize=40)
    line.show_config()
    line.render()

    # line_1
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", attr, v1, is_stack=True, is_label_show=True)
    line.add("商家B", attr, v2, is_stack=True, is_label_show=True)
    line.show_config()
    line.render()

    # line_2
    line = Line("折线图-阶梯图示例")
    line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()

    # # line_3
    line = Line("折线图-面积图示例")
    line.add("商家A", attr, v1, is_fill=True, line_opacity=0.2, area_opacity=0.4, symbol=None)
    line.add("商家B", attr, v2, is_fill=True, area_color='#000', area_opacity=0.3, is_smooth=True)
    line.show_config()
    line.render()

    # line_4
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line = Line("折线图示例")
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"])
    line.show_config()
    line.render()
コード例 #38
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_type_stack():
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", CLOTHES, clothes_v1, is_stack=True, is_label_show=True)
    line.add("商家B", CLOTHES, clothes_v2, is_stack=True, is_label_show=True)
    line.render()
コード例 #39
0
ファイル: test_grid.py プロジェクト: ljwdoc/pyecharts
def test_grid():

    # grid_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%")
    bar.add("商家B", attr, v2, is_stack=True, grid_bottom="60%")
    line = Line("折线图示例", title_top="50%")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_top="50%")
    bar.grid(line.get_series(), grid_top="60%")
    bar.show_config()
    bar.render()

    # grid_1
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter(width=1200, is_grid=True)
    scatter.add("散点图示例", v1, v2, grid_left="60%", legend_pos="70%")
    es = EffectScatter()
    es.add("动态散点图示例", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
           effect_scale=6, legend_pos="20%")
    scatter.grid(es.get_series(), grid_right="60%")
    scatter.show_config()
    scatter.render()

    # grid_2
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, width=1200, title_pos="65%", is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%", grid_left="60%")
    bar.add("商家B", attr, v2, is_stack=True, grid_bottom="60%", grid_left="60%", legend_pos="80%")
    line = Line("折线图示例")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%")
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
    scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")
    es = EffectScatter("动态散点图示例", title_top="50%")
    es.add("es", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0], effect_scale=6,
           legend_top="50%", legend_pos="20%")
    bar.grid(line.get_series(), grid_bottom="60%", grid_right="60%")
    bar.grid(scatter.get_series(), grid_top="60%", grid_left="60%")
    bar.grid(es.get_series(), grid_top="60%", grid_right="60%")
    bar.show_config()
    bar.render()

    # grid_3
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"],
             mark_line=["average"], grid_right="65%")
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [11, 12, 13, 10, 10, 10]
    pie = Pie("饼图示例", title_pos="45%")
    pie.add("", attr, v1, radius=[30, 55], legend_pos="65%", legend_orient='vertical')
    line.grid(pie.get_series(), grid_left="60%")
    line.show_config()
    line.render()

    # grid_4
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"],
             mark_line=["average"], grid_right="60%")
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%", grid_right="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    value = [20, 40, 60, 80, 100, 120]
    v1 = [[2320.26, 2320.26, 2287.3, 2362.94],
          [2300, 2291.3, 2288.26, 2308.38],
          [2295.35, 2346.5, 2295.35, 2345.92],
          [2347.22, 2358.98, 2337.35, 2363.8],
          [2360.75, 2382.48, 2347.89, 2383.76],
          [2383.43, 2385.42, 2371.23, 2391.82],
          [2377.41, 2419.02, 2369.57, 2421.15],
          [2425.92, 2428.15, 2417.58, 2440.38],
          [2411, 2433.13, 2403.3, 2437.42],
          [2432.68, 2334.48, 2427.7, 2441.73],
          [2430.69, 2418.53, 2394.22, 2433.89],
          [2416.62, 2432.4, 2414.4, 2443.03],
          [2441.91, 2421.56, 2418.43, 2444.8],
          [2420.26, 2382.91, 2373.53, 2427.07],
          [2383.49, 2397.18, 2370.61, 2397.94],
          [2378.82, 2325.95, 2309.17, 2378.82],
          [2322.94, 2314.16, 2308.76, 2330.88],
          [2320.62, 2325.82, 2315.01, 2338.78],
          [2313.74, 2293.34, 2289.89, 2340.71],
          [2297.77, 2313.22, 2292.03, 2324.63],
          [2322.32, 2365.59, 2308.92, 2366.16],
          [2364.54, 2359.51, 2330.86, 2369.65],
          [2332.08, 2273.4, 2259.25, 2333.54],
          [2274.81, 2326.31, 2270.1, 2328.14],
          [2333.61, 2347.18, 2321.6, 2351.44],
          [2340.44, 2324.29, 2304.27, 2352.02],
          [2326.42, 2318.61, 2314.59, 2333.67],
          [2314.68, 2310.59, 2296.58, 2320.96],
          [2309.16, 2286.6, 2264.83, 2333.29],
          [2282.17, 2263.97, 2253.25, 2286.33],
          [2255.77, 2270.28, 2253.31, 2276.22]]
    kline = Kline("K 线图示例", title_pos="60%")
    kline.add("日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1, legend_pos="80%")
    line.grid(kline.get_series(), grid_left="55%")
    line.show_config()
    line.render()

    # grid_5
    import random
    x_axis = ["12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a",
              "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p"]
    y_aixs = ["Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday", "Sunday"]
    data = [[i, j, random.randint(0, 50)] for i in range(24) for j in range(7)]
    heatmap = HeatMap("热力图示例", height=700, is_grid=True)
    heatmap.add("热力图直角坐标系", x_axis, y_aixs, data, is_visualmap=True, visual_top="45%",
                visual_text_color="#000", visual_orient='horizontal', grid_bottom="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", title_top="52%")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True, legend_top="50%")
    heatmap.grid(bar.get_series(), grid_top="60%")
    heatmap.show_config()
    heatmap.render()
コード例 #40
0
ファイル: draw_deal_data.py プロジェクト: yunyan/wbmonitor
import sys
import glob
import os
from pyecharts import Line

def load_js(jsfile):
    x_axis = []
    points = []
    with open(jsfile, 'r') as fp:
        while True:
            l = fp.readline()
            if not l:
                break
            deal_dict = json.loads(l)
            x_axis.append(deal_dict['dealDate'][0])
            points.append(deal_dict['unitPrice'][0])
    return x_axis, points

if __name__ == '__main__':
    dir_path = sys.argv[1]
    curve_name = ''
    line = Line("Deal Curve")
    cwd = os.getcwd()
    os.chdir(dir_path)
    for js in glob.glob("*.json"):
        x_axis, points = load_js(js)
        curve_name = js[:js.find(".json")]
        line.add(curve_name, x_axis, points, is_stack=True, is_label_show=True)
    os.chdir(cwd)
    line.render()
コード例 #41
0
ファイル: 折线图.py プロジェクト: gitxw/PythonStudy
#折线图适合描述两个变量之间的函数关系,例如常用它来描述一个变量随时间的变化趋势。

from  pyecharts import Line

x = ['2018-{:0>2d}'.format(s) for s in range(1,13)]
y1 = [5,10,26,30,35,30,20,26,40,46,40,50]
y2 = [8,20,24,36,40,36,40,45,50,53,48,58]

line = Line(title = "月销售总额",width = 600,height = 420)

line.add(name = "商家A", x_axis = x, y_axis = y1,
         line_width = 3,line_color = 'red',
         #=====设置markPoint&markLine=====
         mark_point = ['min','max'], #标记点
         mark_line = ['average']     #标记线
        )

line.add(name = "商家B", x_axis = x, y_axis = y2,
         yaxis_min = 0,yaxis_max = 100,is_xaxis_boundarygap = False,
         is_datazoom_show =True,line_width = 2,line_color = 'cyan',
         #=====设置markPoint&markLine=====
         mark_point = [
            {"coord": ['2018-09', 60], "name": "2018/09销售目标"}, 
            {"coord": ['2018-11', 80], "name": "2018/10销售目标"}]  # 自定义标记点
         )

line.render('result.折线图示范.html')
line