def draw_map_world(data, to_file, svg_name, label_name, number_max):
    """
    画地图
    :param data:
    :param to_file:
    :param svg_name:
    :param label_name: 图例名称
    :param number_max: 最大值
    :return:
    """
    geo = Map(init_opts=opts.InitOpts(width="800px", height="600px", bg_color='rgb(255, 255, 255)')) \
        .add(label_name, data, maptype="world") \
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False),
                         showLegendSymbol=False) \
        .set_global_opts(legend_opts=opts.LegendOpts(item_width=50,
                                                     item_height=30,
                                                     textstyle_opts=opts.TextStyleOpts(font_size=30)),
                         visualmap_opts=opts.VisualMapOpts(min_=0,
                                                           max_=int(number_max),
                                                           background_color='rgb(255, 255, 255)',
                                                           is_piecewise=True,
                                                           item_width=50,
                                                           item_height=30,
                                                           textstyle_opts=opts.TextStyleOpts(font_size=30)),
                         toolbox_opts=opts.ToolboxOpts(
                             feature=opts.ToolBoxFeatureOpts(
                                 data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                                 # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
                             )
                         ),
                         )
    # geo.render(to_file)
    make_snapshot(snapshot, geo.render(to_file), svg_name)  # 生成svg图片
def draw_river_picture_right_legend(series_name,
                                    data,
                                    to_file,
                                    svg_name,
                                    pos_right,
                                    width='800px'):
    """
    主题河流图
    :param width:
    :param pos_right:
    :param series_name: [str]
    :param data: [[date, value, series_name]]
    :param svg_name: svg文件
    :param to_file: 结果文件
    :return:
    """
    bar = ThemeRiver(init_opts=opts.InitOpts(width="800px", height="600px", bg_color='white')) \
        .add(
        series_name=series_name,
        data=data,
        singleaxis_opts=opts.SingleAxisOpts(
            pos_top="50",
            pos_bottom="50",
            type_="time",
            name_textstyle_opts=opts.TextStyleOpts(font_size=20),
            axislabel_opts=opts.LabelOpts(font_size=20)
        ),
        label_opts=opts.LabelOpts(is_show=False),
    ) \
        .set_global_opts(
        tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="line"),
        toolbox_opts=opts.ToolboxOpts(
            feature=opts.ToolBoxFeatureOpts(
                data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
            )
        ),
        legend_opts=opts.LegendOpts(pos_right=pos_right,
                                    pos_top="2%",
                                    orient="vertical",
                                    item_width=30,
                                    item_height=14,
                                    textstyle_opts=opts.TextStyleOpts(font_size=18)
                                    ),
    )
    grid = (Grid(init_opts=opts.InitOpts(
        width=width, height="600px", bg_color='rgb(255, 255, 255)')).add(
            bar,
            grid_opts=opts.GridOpts(pos_right='10%'),
            is_control_axis_index=True))
    make_snapshot(snapshot, grid.render(to_file), svg_name)  # 生成svg图片
Exemple #3
0
def to_treemap(data, proj, version):
    complexity = {'name': f'{proj}-{version}', 'children': []}
    extract(complexity, 'complexity', data)
    maintainability = {'name': f'{proj}-{version}', 'children': []}
    extract(maintainability, 'maintainability', data)
    testability = {'name': f'{proj}-{version}', 'children': []}
    extract(testability, 'testability', data)
    readability = {'name': f'{proj}-{version}', 'children': []}
    extract(readability, 'readability', data)
    reusability = {'name': f'{proj}-{version}', 'children': []}
    extract(reusability, 'reusability', data)
    inheritance = {'name': f'{proj}-{version}', 'children': []}
    extract(inheritance, 'inheritance', data)

    treemap = TreeMap()
    for indicator in [
            'complexity', 'maintainability', 'testability', 'readability',
            'reusability', 'inheritance'
    ]:
        treemap = treemap.add(series_name=indicator,
                              data=[locals()[indicator]],
                              leaf_depth=2,
                              roam=False,
                              label_opts=opts.LabelOpts(position='inside'))

    treemap = (treemap.set_global_opts(
        tooltip_opts=opts.TooltipOpts(formatter='{b}<br/>{a}: {c}'),
        toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
            magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False),
            data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
            brush=opts.ToolBoxFeatureBrushOpts(type_='clear'))),
        legend_opts=opts.LegendOpts(is_show=True,
                                    selected_mode='single',
                                    pos_top='7%',
                                    orient='horizontal',
                                    padding=0),
        title_opts=opts.TitleOpts(
            title=f'Code Quality Treemap of {proj}-{version}',
            pos_left='center')))
    grid = Grid()
    grid.add(treemap, grid_opts=opts.GridOpts(pos_top='100%'))
    return grid
Exemple #4
0
def to_linechart(data, proj):
    versions = [version['version_name'] for version in data]
    linechart = Line().add_xaxis(xaxis_data=versions)
    for indicator in [
            'complexity', 'maintainability', 'testability', 'readability',
            'reusability', 'inheritance'
    ]:
        linechart = linechart.add_yaxis(
            series_name=indicator,
            y_axis=[round(version[indicator], 2) for version in data],
            is_smooth=True,
            label_opts=opts.LabelOpts(is_show=False),
            linestyle_opts=opts.LineStyleOpts(width=2),
        )

    linechart = (linechart.set_global_opts(
        tooltip_opts=opts.TooltipOpts(trigger="axis",
                                      axis_pointer_type="cross"),
        xaxis_opts=opts.AxisOpts(boundary_gap=False),
        yaxis_opts=opts.AxisOpts(
            axislabel_opts=opts.LabelOpts(formatter="{value}"),
            splitline_opts=opts.SplitLineOpts(is_show=True),
        ),
        toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
            magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False),
            data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
            brush=opts.ToolBoxFeatureBrushOpts(type_='clear'))),
        legend_opts=opts.LegendOpts(is_show=True,
                                    pos_top='middle',
                                    pos_left='1%',
                                    orient='vertical',
                                    padding=0),
        datazoom_opts=opts.DataZoomOpts(type_='slider',
                                        range_start=0,
                                        range_end=100),
        title_opts=opts.TitleOpts(title=f'Code Quality Linechart of {proj}',
                                  pos_left='center')))
    grid = Grid()
    grid.add(linechart, grid_opts=opts.GridOpts(pos_left='150'))
    return grid
Exemple #5
0
 def dayloss_line_base(self, x, y, t, st):
     c = (Line(
         init_opts=opts.InitOpts(width="1000px", height="500px")
     ).add_xaxis(x).add_yaxis("线损率(%)", y, is_smooth=True).set_global_opts(
         tooltip_opts=opts.TooltipOpts(is_show=True,
                                       trigger="axis",
                                       axis_pointer_type="cross"),
         title_opts=opts.TitleOpts(title=t, subtitle=st),
         xaxis_opts=opts.AxisOpts(
             axislabel_opts=opts.LabelOpts(rotate=-90),
             max_interval=366,
             type_="category",
             axispointer_opts=opts.AxisPointerOpts(is_show=True,
                                                   type_="shadow"),
         ),
         yaxis_opts=opts.AxisOpts(
             axislabel_opts=opts.LabelOpts(formatter="{value} %"),
             axistick_opts=opts.AxisTickOpts(is_show=True),
             splitline_opts=opts.SplitLineOpts(is_show=True),
         ),
         toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
             save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                 pixel_ratio=2, background_color='white'),
             restore=opts.ToolBoxFeatureRestoreOpts(is_show=False),
             data_view=opts.ToolBoxFeatureDataViewOpts(is_show=False),
             data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
             magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False),
             brush=opts.ToolBoxFeatureBrushOpts(type_='clear'),
         ))).set_series_opts(
             label_opts=opts.LabelOpts(is_show=False),
             markline_opts=opts.MarkLineOpts(
                 data=[
                     opts.MarkLineItem(y=6),
                 ],
                 label_opts=opts.LabelOpts(is_show=False),
             ),
         ))
     return c
 def __init__(self, title: str, output: str):
     self.title = title
     self.output = output
     self.datas = []
     self.chart = (Line(init_opts=opts.InitOpts(
         page_title=self.title,
         theme=ThemeType.DARK,
         width="1280px",
         height="720px",
     )).set_global_opts(
         title_opts=opts.TitleOpts(title=self.title),
         xaxis_opts=opts.AxisOpts(type_="value",
                                  is_scale=True,
                                  split_number=10,
                                  name="bitrate/kbps"),
         yaxis_opts=opts.AxisOpts(type_="value", is_scale=True,
                                  name="vmaf"),
         toolbox_opts=opts.ToolboxOpts(
             is_show=True,
             orient="vertical",
             pos_left="right",
             feature=opts.ToolBoxFeatureOpts(
                 save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                     title="save as image", is_show=True),
                 restore=opts.ToolBoxFeatureRestoreOpts(is_show=False),
                 data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                 data_view=opts.ToolBoxFeatureDataViewOpts(
                     is_show=False, is_read_only=True, title="data"),
                 magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False),
                 brush=opts.ToolBoxFeatureBrushOpts(type_=[]))),
         legend_opts=opts.LegendOpts(pos_top="bottom"),
         tooltip_opts=opts.TooltipOpts(
             is_show=True,
             formatter=pyecharts_utils.JsCode(
                 "function(x) {return x.seriesName + '<br/>bitrate&nbsp;&nbsp;'+ x.data[0] + '&nbsp;kbps<br/>vmaf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + x.data[1];}"
             ))))
def draw_bar_reverse_picture(xaxis_data,
                             data,
                             to_file,
                             unit,
                             svg_name,
                             stack,
                             y_name,
                             pos_left='25%'):
    """
    多个y列,是否堆叠要确认下
    :param pos_left: "25%"
    :param is_reverse: xy轴是否反转
    :param y_name: y轴名称
    :param stack: boolean, 是否要堆叠
    :param xaxis_data: x轴
    :param data: {series_name, data}
    :param svg_name: svg文件
    :param to_file: 结果文件
    :param unit: 横轴的数值的单位(加在每个横轴值后面,比如 月)
    :return:
    """
    xaxis_data = [str(i) + unit for i in xaxis_data]
    bar = Bar(init_opts=opts.InitOpts(
        width="800px", height="600px", bg_color='white')).add_xaxis(  # 1250px
            xaxis_data=xaxis_data,
            # add_xaxis=opts.LabelOpts(formatter="{value}" + unit),
        )
    for series_name, y_axis in data.items():
        if stack:
            bar = bar.add_yaxis(
                series_name=series_name,
                stack='1',
                # color="#d14a61",
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=False),
            )
        else:
            bar = bar.add_yaxis(
                series_name=series_name,
                color="#61a0a8",
                category_gap='50%',
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=True, position='right'),
            )
    bar = bar.set_global_opts(
        yaxis_opts=opts.AxisOpts(
            type_="category",
            # min_=0,
            # max_=250,
            position="left",
            offset=0,
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts()),
            axislabel_opts=opts.LabelOpts(formatter="{value}", font_size=20),
        ),
        xaxis_opts=opts.AxisOpts(
            name=y_name,
            name_textstyle_opts=opts.TextStyleOpts(font_size=20),
            axislabel_opts=opts.LabelOpts(formatter="{value}", font_size=20),
        ),
        tooltip_opts=opts.TooltipOpts(trigger="axis",
                                      axis_pointer_type="cross"),
        toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
            data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
            # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
        )),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    bar = bar.reversal_axis()
    grid = (
        Grid(init_opts=opts.InitOpts(width="800px",
                                     height="600px",
                                     bg_color='rgb(255, 255, 255)'))  # 800px
        .add(bar,
             grid_opts=opts.GridOpts(pos_left=pos_left),
             is_control_axis_index=True))
    make_snapshot(snapshot, grid.render(to_file), svg_name)  # 生成svg图片
def draw_bar_picture(xaxis_data, data, to_file, unit, svg_name, stack, y_name):
    """
    多个y列,是否堆叠要确认下
    :param is_reverse: xy轴是否反转
    :param y_name: y轴名称
    :param stack: boolean, 是否要堆叠
    :param xaxis_data: x轴
    :param data: {series_name, data}
    :param svg_name: svg文件
    :param to_file: 结果文件
    :param unit: 横轴的数值的单位(加在每个横轴值后面,比如 月)
    :return:
    """
    xaxis_data = [str(i) + unit for i in xaxis_data]
    bar = Bar(init_opts=opts.InitOpts(
        width="900px", height="600px", bg_color='white')).add_xaxis(
            xaxis_data=xaxis_data,
            # add_xaxis=opts.LabelOpts(formatter="{value}" + unit),
        )
    for series_name, y_axis in data.items():
        if stack:
            bar = bar.add_yaxis(
                series_name=series_name,
                stack='1',
                # color="#d14a61",
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=False),
            )
        else:
            bar = bar.add_yaxis(
                series_name=series_name,
                # color="#d14a61",
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=False),
            )
    bar = bar.set_global_opts(
        yaxis_opts=opts.AxisOpts(
            type_="value",
            name=y_name,
            name_textstyle_opts=opts.TextStyleOpts(font_size=15),
            # min_=0,
            # max_=250,
            position="left",
            offset=0,
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts()),
            axislabel_opts=opts.LabelOpts(formatter="{value}", font_size=15),
        ),
        xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
            formatter="{value}", font_size=15, interval=0), ),
        tooltip_opts=opts.TooltipOpts(trigger="axis",
                                      axis_pointer_type="cross"),
        toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
            data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
            # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
        )),
        legend_opts=opts.LegendOpts(
            item_width=25,
            item_height=15,
            textstyle_opts=opts.TextStyleOpts(font_size=15)),
    )
    make_snapshot(snapshot, bar.render(to_file), svg_name)  # 生成svg图片
def draw_line_picture(xaxis_data, data, to_file, unit, svg_name, stack,
                      y_name):
    """
    多条线,是否堆叠要确认下
    :param label_right:
    :param y_name: y轴名称
    :param stack: boolean, 是否要堆叠
    :param xaxis_data: x轴
    :param data: {series_name, data}
    :param svg_name: svg文件
    :param to_file: 结果文件
    :param unit: 横轴的数值的单位(加在每个横轴值后面,比如 月)
    :return:
    """
    xaxis_data = [str(i) + unit for i in xaxis_data]
    bar = Line(init_opts=opts.InitOpts(
        width="800px", height="600px", bg_color='white')).add_xaxis(
            xaxis_data=xaxis_data,
            # add_xaxis=opts.LabelOpts(formatter="{value}" + unit),
        )
    for series_name, y_axis in data.items():
        if stack:
            bar = bar.add_yaxis(
                series_name=series_name,
                is_smooth=True,
                symbol="circle",
                # symbol_size=8,
                stack='1',
                is_symbol_show=False,
                # color="#d14a61",
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=False),
                # linestyle_opts=opts.LineStyleOpts(width=2),
                areastyle_opts=opts.AreaStyleOpts(opacity=1))
        else:
            bar = bar.add_yaxis(
                series_name=series_name,
                is_smooth=True,
                symbol="circle",
                symbol_size=8,
                is_symbol_show=True,
                # color="#d14a61",
                y_axis=y_axis,
                yaxis_index=0,
                label_opts=opts.LabelOpts(is_show=False),
                linestyle_opts=opts.LineStyleOpts(width=2),
            )
    bar = bar.set_global_opts(
        yaxis_opts=opts.AxisOpts(
            type_="value",
            name=y_name,
            name_textstyle_opts=opts.TextStyleOpts(font_size=25),
            # min_=0,
            # max_=250,
            position="left",
            offset=0,
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts()),
            axislabel_opts=opts.LabelOpts(formatter="{value}", font_size=25),
        ),
        xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
            formatter="{value}", font_size=25, interval=0), ),
        tooltip_opts=opts.TooltipOpts(trigger="axis",
                                      axis_pointer_type="cross"),
        toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
            data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
            # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
        )),
        legend_opts=opts.LegendOpts(
            pos_left="12%",
            pos_top="10%",
            orient="vertical",
            # backgroundColor='rgb(255, 255, 255)',
            item_width=40,
            item_height=20,
            textstyle_opts=opts.TextStyleOpts(font_size=25)),
    )
    make_snapshot(snapshot, bar.render(to_file), svg_name)  # 生成svg图片
def draw_line_with_two_y(xaxis_data, y1_series_name, y1_axis, y2_series_name,
                         y2_axis, y3_series_name, y3_axis, y1_name, y2_name,
                         to_file, unit, svg_name):
    """
    左边是  两条线; 右边是 一条线。
    :param svg_name: svg文件
    :param xaxis_data: 横轴
    :param y1_series_name: 左边第一条线的系列名
    :param y1_axis: 左边第一条线的数值
    :param y2_series_name: 左边第二条线的系列名
    :param y2_axis: 左边第二条线的数值
    :param y3_series_name: 右边第一条线的系列名
    :param y3_axis: 右边第一条线的数值
    :param y1_name: 左边的纵轴名称
    :param y2_name: 右边的纵轴名称
    :param to_file: 结果文件
    :param unit: 横轴的数值的单位(加在每个横轴值后面,比如 月)
    :return:
    """
    xaxis_data = [str(i) + unit for i in xaxis_data]
    bar = Line(init_opts=opts.InitOpts(
        width="800px", height="600px", bg_color='white'
    )).add_xaxis(
        xaxis_data=xaxis_data,
        # add_xaxis=opts.LabelOpts(formatter="{value}" + unit),
    ).add_yaxis(
        series_name=y1_series_name,
        is_smooth=True,
        symbol="circle",
        symbol_size=8,
        is_symbol_show=True,
        # color="#d14a61",
        y_axis=y1_axis,
        yaxis_index=0,
        label_opts=opts.LabelOpts(is_show=False),
        linestyle_opts=opts.LineStyleOpts(width=2),
    ).add_yaxis(
        series_name=y2_series_name,
        is_smooth=True,
        symbol="circle",
        symbol_size=8,
        is_symbol_show=True,
        # color="#d14a61",
        y_axis=y2_axis,
        yaxis_index=0,
        label_opts=opts.LabelOpts(is_show=False),
        linestyle_opts=opts.LineStyleOpts(width=2),
    ).add_yaxis(
        series_name=y3_series_name,
        is_smooth=True,
        symbol="circle",
        symbol_size=8,
        is_symbol_show=True,
        # color="#d14a61",
        y_axis=y3_axis,
        yaxis_index=1,
        label_opts=opts.LabelOpts(is_show=False),
        linestyle_opts=opts.LineStyleOpts(width=2),
    ).extend_axis(yaxis=opts.AxisOpts(
        type_="value",
        name=y2_name,
        # min_=0,
        # max_=25,
        position="right",
        axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts()),
        axislabel_opts=opts.LabelOpts(formatter="{value}", font_size=15),
        splitline_opts=opts.SplitLineOpts(
            is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)),
        name_textstyle_opts=opts.TextStyleOpts(font_size=15))).set_global_opts(
            yaxis_opts=opts.AxisOpts(
                type_="value",
                name=y1_name,
                # min_=0,
                # max_=250,
                position="left",
                offset=0,
                axisline_opts=opts.AxisLineOpts(
                    linestyle_opts=opts.LineStyleOpts()),
                axislabel_opts=opts.LabelOpts(formatter="{value}",
                                              font_size=15),
                name_textstyle_opts=opts.TextStyleOpts(font_size=15)),
            xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
                formatter="{value}", font_size=15), ),
            tooltip_opts=opts.TooltipOpts(trigger="axis",
                                          axis_pointer_type="cross"),
            toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
            )),
            legend_opts=opts.LegendOpts(
                item_width=25,
                item_height=10,
                textstyle_opts=opts.TextStyleOpts(font_size=15)),
        )
    make_snapshot(snapshot, bar.render(to_file), svg_name)  # 生成svg图片
Exemple #11
0
    def day_sxdl(self, x, mc, a, b, c, k):
        c = (Line(
            init_opts=opts.InitOpts(width="1000px", height="500px")
        ).add_xaxis(x).add_yaxis("电压A", a, is_smooth=True).add_yaxis(
            "电压B", b, is_smooth=True).add_yaxis(
                "电压C", c, is_smooth=True).set_global_opts(
                    tooltip_opts=opts.TooltipOpts(is_show=True,
                                                  trigger="axis",
                                                  axis_pointer_type="cross"),
                    title_opts={
                        'text': mc,
                        'subtext': None
                    },
                    xaxis_opts=opts.AxisOpts(
                        axislabel_opts=opts.LabelOpts(rotate=-90),
                        max_interval=366,
                        type_="category",
                        axispointer_opts=opts.AxisPointerOpts(is_show=True,
                                                              type_="shadow"),
                    ),
                    yaxis_opts=opts.AxisOpts(
                        axislabel_opts=opts.LabelOpts(formatter="{value} v"),
                        axistick_opts=opts.AxisTickOpts(is_show=True),
                        splitline_opts=opts.SplitLineOpts(is_show=True),
                    ),
                    toolbox_opts=opts.
                    ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                        save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                            pixel_ratio=2, background_color='white'),
                        restore=opts.ToolBoxFeatureRestoreOpts(is_show=False),
                        data_view=opts.ToolBoxFeatureDataViewOpts(
                            is_show=False),
                        data_zoom=opts.ToolBoxFeatureDataZoomOpts(
                            is_show=False),
                        magic_type=opts.ToolBoxFeatureMagicTypeOpts(
                            is_show=False),
                        brush=opts.ToolBoxFeatureBrushOpts(type_='clear'),
                    ))).set_series_opts(label_opts=opts.LabelOpts(
                        is_show=False), ).extend_axis(
                            yaxis=opts.AxisOpts(name='方差',
                                                axislabel_opts=opts.LabelOpts(
                                                    formatter="{value} "))))
        line1 = Line().add_xaxis(x).add_yaxis(
            "方差",
            k,
            yaxis_index=1,
            is_smooth=True,
            linestyle_opts=opts.LineStyleOpts(
                color="black", width=2, type_="solid")).set_series_opts(
                    label_opts=opts.LabelOpts(is_show=False), )
        c.overlap(line1)
        return c


#     def day_loss_1(self,x,y,t,st,z,m):
#         c = self.dayloss_line_base(x,y,t,st)
#         c = c.extend_axis(
#                 yaxis=opts.AxisOpts(
#                     axislabel_opts=opts.LabelOpts(formatter="{value} kWh")
#                 )
#             ).extend_axis(
#                 yaxis=opts.AxisOpts(
#                     name = '数据完整率',
#                     position = 'right',
#                     offset = 62,
#                     axislabel_opts=opts.LabelOpts(formatter="{value} "),
#                     axisline_opts=opts.AxisLineOpts(
#                         linestyle_opts=opts.LineStyleOpts(color="#675bba")
#                     ),

#                 )
#             )

#         line = Line().add_xaxis(x).add_yaxis("供入电量", z,yaxis_index=1,is_smooth=True).set_series_opts(
#                 label_opts=opts.LabelOpts(is_show=False), )

#         line_1 = Line().add_xaxis(x).add_yaxis("数据完整率", m,yaxis_index=2).set_series_opts(
#                 label_opts=opts.LabelOpts(is_show=False), )

#         c.overlap(line)
#         c.overlap(line_1)
#         return c

#     def day_loss_2(self,x,y,t,st,a,b):
#         c = self.dayloss_line_base(x,y,t,st)
#         c = c.extend_axis(
#                 yaxis=opts.AxisOpts(
#                     axislabel_opts=opts.LabelOpts(formatter="{value} kWh")
#                 )
#             )
#         line = Line().add_xaxis(a).add_yaxis("用电量", b,yaxis_index=1,is_smooth=True).set_series_opts(
#             label_opts=opts.LabelOpts(is_show=False), )

#         c.overlap(line)
#         return c

# class electricity():
#     """docstring for electricity"""
#     def __init__(self,df):
#         self.df = df

#     def day_data(self,a):
#         tq = self.df[self.df.测量点号==a][['数据时间','正向']].set_index('数据时间').sort_values(by='数据时间')
#         x = [i[-5:] for i in tq.index]
#         y = [float(i[0]) for i in tq.values]
#         t = a
#         return x,y,t

#     def measure_num(self):
#         num = set(i for i in self.df.测量点号)
#         num = list(num)[1:]
#         return num

# class relation(object):
#     """docstring for relation"""

#     def curr_relation(self,x,y,a,b):
#         lineloss = pd.Series(y,index=x)
#         day_electricity = pd.Series(b,index= a)
#         c = lineloss.corr(day_electricity)
# #         c1 = lineloss.cov(day_electricity)
#         return c

# IO = '石鼓12月.xls'
# k = []
# day_loss = data(IO)

# tq_index = day_loss.day_lineloss_index()

# for i in tq_index:
#     x,y,a,z,m = data(IO).day_lineloss(i)
#     nc = relation().curr_relation(x,y,x,z)
#     c = drawing().day_loss_1(x,y, a+ str(nc),z,m)

#     k.append(c)

# drawing().all_day_lineloss(k,'石鼓12')

# IO = '石鼓12月.xls'
# name = '宝丰12.xlsx'
# num = electricity(name).measure_num()
# day_loss = data(IO)
# a,b,j,z,m = data(IO).day_lineloss('宝丰公用台变')

# k1 = []
# for i in num:
#     x,y,t = electricity(name).day_data(i)
#     c = relation().curr_relation(a,b,x,y)
#     c1 = drawing().day_loss_2(a,b,str(t)+' & '+str(c),x,y)
#     k1.append(c1)

# ny = np.array(electricity(name).day_data(92)[1]) + np.array(electricity(name).day_data(37)[1])

# c = relation().curr_relation(a,b,x,ny)

# c1 = drawing().day_loss_2(a,b,'9237'+str(c),x,ny)

# k1.append(c1)

# drawing().all_day_lineloss(k1,'宝丰12')

# k2 = []
# for i in num:
#     x,y,t = electricity(name).day_data(i)
#     c = relation().curr_relation(a,b,x,y)
#     k2.append(c)
#     print(str(c) + 10*'-'+str(i))
#     print(10*'--')

# k3 = []
# nyy= []
# for i in num:
#     x,y,t = electricity(name).day_data(i)
#     c = relation().curr_relation(a,b,x,y)
#     print(c[0])
#     if c[0] > 0.5:
#         nyy.append(np.array(y))
#         c1 = drawing().day_loss_2(a,b,t,x,y)
#         k3.append(c1)

# c2 = drawing().day_loss_2(a,b,'all',x,sum(nyy))
# k3.append(c2)

# drawing().all_day_lineloss(k3,'test_class_5')
# c = relation().curr_relation(a,b,x,sum(nyy))
# print(c)
Exemple #12
0
def html_plot(file):
    sp = file.split(".")
    with open(file) as f:
        l = f.readlines()
        i = 0
        ks = {}
        for line in l:
            if i == 0:
                head = line.strip().split("\t")
                i = 1
            else:
                t = line.strip().split("\t")
                name = t[0]
                del t[0]
                ks[name] = t
        bar = Bar(init_opts=opts.InitOpts(
            page_title=sp[0] + "-ks.htmlpolt", width="1500px", height="700px"))
        bar.add_xaxis(head)
        for key, value in ks.items():
            bar.add_yaxis(key,
                          value,
                          category_gap=0,
                          stack="stack1",
                          is_large=True)
        bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        bar.set_global_opts(
            title_opts=opts.TitleOpts(title=sp[0] + ".ks.polt",
                                      subtitle="Plot by Tree2gd v1.0"),
            toolbox_opts=opts.ToolboxOpts(
                is_show=True,
                pos_top='10%',
                orient='vertical',
                pos_left='right',
                feature=opts.ToolBoxFeatureOpts(
                    save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                        title="Save as png"),
                    restore=opts.ToolBoxFeatureRestoreOpts(title="Recovery"),
                    data_view=opts.ToolBoxFeatureDataViewOpts(
                        title="Data", lang=['Data View', 'Close', 'Refresh']),
                    data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                    magic_type=opts.ToolBoxFeatureMagicTypeOpts(
                        line_title="Switch to line plot",
                        bar_title="Switch to histogram plot",
                        stack_title="Switch to stack plot",
                        tiled_title="Switch to tiled plot"),
                    brush=opts.ToolBoxFeatureBrushOpts(
                        rect_title="Rectangle selection",
                        polygon_title="Circle selection",
                        line_x_title="X line selection",
                        line_y_title="Y line selection",
                        keep_title="Keep selection",
                        clear_title="Clear selection"),
                )),
            legend_opts=opts.LegendOpts(pos_left='right', ),
            datazoom_opts=[
                opts.DataZoomOpts(range_start=0, range_end=60),
                opts.DataZoomOpts(type_="inside")
            ],
            xaxis_opts=opts.AxisOpts(name="Ks"),
        )
        bar.render(os.sep.join(["..", "ks_html_plot",
                                sp[0] + ".ks.plot.html"]))
Exemple #13
0
    def day_sxdl(self, x, mc, a, b, c, m, n, rca, rcb, rcc, j, rcj):
        c = (Line(
            init_opts=opts.InitOpts(width="1000px", height="500px")
        ).add_xaxis(x).add_yaxis(
            "电流A",
            a,
            is_smooth=True,
            itemstyle_opts=opts.ItemStyleOpts(color='black')).add_yaxis(
                "电流B",
                b,
                is_smooth=True,
                itemstyle_opts=opts.ItemStyleOpts(color='blue')).add_yaxis(
                    "电流C",
                    c,
                    is_smooth=True,
                    itemstyle_opts=opts.ItemStyleOpts(
                        color='green')).set_global_opts(
                            tooltip_opts=opts.TooltipOpts(
                                is_show=True,
                                trigger="axis",
                                axis_pointer_type="cross"),
                            title_opts=opts.TitleOpts(
                                title=mc,
                                subtitle='A: ' + str(rca)[:12] + '  ' + 'B: ' +
                                str(rcb)[:12] + '  ' + 'C: ' + str(rcc)[:12] +
                                '  '),
                            xaxis_opts=opts.AxisOpts(
                                axislabel_opts=opts.LabelOpts(rotate=-90),
                                max_interval=366,
                                type_="category",
                                axispointer_opts=opts.AxisPointerOpts(
                                    is_show=True, type_="shadow"),
                            ),
                            yaxis_opts=opts.AxisOpts(
                                axislabel_opts=opts.LabelOpts(
                                    formatter="{value} A"),
                                axistick_opts=opts.AxisTickOpts(is_show=True),
                                splitline_opts=opts.SplitLineOpts(
                                    is_show=True),
                            ),
                            toolbox_opts=opts.
                            ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                                save_as_image=opts.
                                ToolBoxFeatureSaveAsImageOpts(
                                    pixel_ratio=2, background_color='white'),
                                restore=opts.ToolBoxFeatureRestoreOpts(
                                    is_show=False),
                                data_view=opts.ToolBoxFeatureDataViewOpts(
                                    is_show=False),
                                data_zoom=opts.ToolBoxFeatureDataZoomOpts(
                                    is_show=False),
                                magic_type=opts.ToolBoxFeatureMagicTypeOpts(
                                    is_show=False),
                                brush=opts.ToolBoxFeatureBrushOpts(
                                    type_='clear'),
                            ))).set_series_opts(
                                label_opts=opts.LabelOpts(is_show=False), ).
             extend_axis(yaxis=opts.AxisOpts(name='线损率',
                                             axislabel_opts=opts.LabelOpts(
                                                 formatter="{value} %"))))

        line = (Line(init_opts=opts.InitOpts(
            width="1000px", height="500px")).add_xaxis(m).add_yaxis(
                "线损率",
                n,
                is_smooth=True,
                linestyle_opts=opts.LineStyleOpts(color="red",
                                                  width=2,
                                                  type_="solid")
            ).set_series_opts(
                label_opts=opts.LabelOpts(is_show=False), ).set_global_opts(
                    tooltip_opts=opts.TooltipOpts(is_show=True,
                                                  trigger="axis",
                                                  axis_pointer_type="cross"),
                    title_opts=opts.TitleOpts(title=mc,
                                              subtitle='相关性系数: ' +
                                              str(rcj)[:12]),
                    xaxis_opts=opts.AxisOpts(
                        axislabel_opts=opts.LabelOpts(rotate=-90),
                        max_interval=366,
                        type_="category",
                        axispointer_opts=opts.AxisPointerOpts(is_show=True,
                                                              type_="shadow"),
                    ),
                    yaxis_opts=opts.AxisOpts(
                        axislabel_opts=opts.LabelOpts(formatter="{value} %"),
                        axistick_opts=opts.AxisTickOpts(is_show=True),
                        splitline_opts=opts.SplitLineOpts(is_show=True),
                    ),
                    toolbox_opts=opts.
                    ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                        save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                            pixel_ratio=2, background_color='white'),
                        restore=opts.ToolBoxFeatureRestoreOpts(is_show=False),
                        data_view=opts.ToolBoxFeatureDataViewOpts(
                            is_show=False),
                        data_zoom=opts.ToolBoxFeatureDataZoomOpts(
                            is_show=False),
                        magic_type=opts.ToolBoxFeatureMagicTypeOpts(
                            is_show=False),
                        brush=opts.ToolBoxFeatureBrushOpts(type_='clear'),
                    ))).set_series_opts(label_opts=opts.LabelOpts(
                        is_show=False), ).extend_axis(
                            yaxis=opts.AxisOpts(name='方差',
                                                axislabel_opts=opts.LabelOpts(
                                                    formatter="{value} "))))

        line3 = (Line().add_xaxis(m).add_yaxis(
            "线损率",
            n,
            yaxis_index=1,
            is_smooth=True,
            is_selected=False,
            linestyle_opts=opts.LineStyleOpts(
                color="red", width=2, type_="dotted")).set_series_opts(
                    label_opts=opts.LabelOpts(is_show=False), ))

        line1 = Line().add_xaxis(x).add_yaxis(
            "方差",
            j,
            yaxis_index=1,
            is_smooth=True,
            linestyle_opts=opts.LineStyleOpts(
                color="black", width=2, type_="solid")).set_series_opts(
                    label_opts=opts.LabelOpts(is_show=False), )

        d = line.overlap(line1)

        c.overlap(line3)
        return c, d
Exemple #14
0
 def Plot(self, jine: list, hushu: list, coef: list, date :str = None, title : str = None, size_def = lambda x: 50 if 10 + x > 50 else 10 + x):
     
     ##配置全局变量
     j_list = [0 for _ in jine]
     h_list = [0 for _ in hushu]
     plot = Scatter(init_opts = opts.InitOpts(width = self.width, height = self.height, theme = self.theme))
     plot.set_global_opts(
                         title_opts=opts.TitleOpts(title=title),
                         xaxis_opts = opts.AxisOpts(type_="value", 
                                                    splitline_opts=opts.SplitLineOpts(is_show=False), 
                                                    min_ = self.x_min, max_ = self.x_max, 
                                                    name = self.data_name[self.x_index]),
                         yaxis_opts = opts.AxisOpts(type_="value", 
                                                    splitline_opts=opts.SplitLineOpts(is_show=False), 
                                                    min_ = self.y_min, max_ = self.y_max, 
                                                    name = self.data_name[self.y_index]),
                         toolbox_opts = opts.ToolboxOpts(orient = 'horizontal', pos_top = 0,
                                                         feature = opts.ToolBoxFeatureOpts(
                                                         save_as_image = opts.ToolBoxFeatureSaveAsImageOpts(type_ = "jpeg", pixel_ratio = 4, background_color = 'white'),
                                                         restore = opts.ToolBoxFeatureRestoreOpts(),
                                                         data_zoom = opts.ToolBoxFeatureDataZoomOpts(),
                                                         data_view = opts.ToolBoxFeatureDataViewOpts(is_show = False),
                                                         magic_type = opts.ToolBoxFeatureMagicTypeOpts(is_show = False),
                                                         brush = opts.ToolBoxFeatureBrushOpts(type_=[]))),
                         tooltip_opts=opts.TooltipOpts(is_show=True, trigger="item", axis_pointer_type="cross")
                         )
     
     ##逐个添加点
     for item in self.data_value:
         
         #数据处理
         local = str(item[self.local_index])
         num = float(item[self.x_index])
         gold = float(item[self.y_index])
         name = str(item[self.name_index])
         size = 0.
         for s in range(len(self.size_index)):
             size += item[self.size_index[s]]*self.size_coef[s]
         tips = '日期:{}'.format(date)
         for s in range(len(self.data_name)):
             tips += '<br>'
             tips += '{}:{}'.format(self.data_name[s], item[s])
         
         #添加点及其tips
         plot.add_xaxis([num])
         plot.add_yaxis(local, [gold], symbol_size = size_def(size),
                        tooltip_opts=opts.TooltipOpts(formatter = tips),
                        label_opts=opts.LabelOpts(formatter = name))
         
         #计算达标人数
         for i in range(len(j_list)):
             if gold >= jine[i]:
                 j_list[i] += 1
         for i in range(len(h_list)):
             if num >= hushu[i]:
                 h_list[i] += 1
                 
     ##添加达标线及其注释点
     for item in range(len(j_list)):
         plot.add_xaxis([self.x_max])
         plot.add_yaxis('达标线', [jine[item]], symbol_size = 25, symbol = 'pin',
                        label_opts = opts.LabelOpts(is_show = False),
                        tooltip_opts = opts.TooltipOpts(formatter = '达标人数:{}<br>未达标人数:{}'.format(j_list[item], self.num-j_list[item])),
                        markline_opts = opts.MarkLineOpts(data = [opts.MarkLineItem(y = jine[item], name = '金额达标线{}'.format(i+1))],
                                                          label_opts = opts.LabelOpts(is_show = False),
                                                          symbol_size = 0))
         
     for item in range(len(h_list)):
         plot.add_xaxis([hushu[item]])
         plot.add_yaxis('达标线', [self.y_max], symbol_size = 25, symbol = 'pin',
                        label_opts = opts.LabelOpts(is_show = False),
                        tooltip_opts = opts.TooltipOpts(formatter = '奖励系数:x{}<br>达标人数:{}<br>未达标人数:{}'.format(coef[item], h_list[item], self.num-h_list[item])),
                        markline_opts = opts.MarkLineOpts(data = [opts.MarkLineItem(x = hushu[item], name = '户数达标线{}'.format(i+1))],
                                                          label_opts = opts.LabelOpts(is_show = False),
                                                          symbol_size = 0)) 
     
     return plot
Exemple #15
0
    def plot_ground_truth_analysis(
        all_score_columns: typing.List[str],
        title: str,
        output_path: str,
        df: pd.DataFrame,
        add_wrong_candidates: bool = False,
        wrong_candidates_score_column: str = None,
    ) -> None:
        """
        use pyechart to plot html interactive figure
        """
        df_processed = copy.deepcopy(df)
        for each_col in df_processed.columns:
            df_processed[each_col] = pd.to_numeric(df_processed[each_col],
                                                   errors='ignore')

        xaxis_labels = []
        memo = defaultdict(list)

        groupby_res = df_processed[df_processed["evaluation_label"] ==
                                   1].groupby(["column", "row"])
        for key, each_group in reversed(tuple(groupby_res)):
            if add_wrong_candidates:
                df_wrong_examples = df_processed[(df_processed["column"] == key[0]) &
                                                 (df_processed["row"] == key[1]) &
                                                 (df_processed["evaluation_label"] == -1)] \
                                        .sort_values(by=[wrong_candidates_score_column], ascending=False).iloc[:3, :]
                # add wrong candidate information
                for _, each_row in df_wrong_examples.iterrows():
                    longest_string = max(each_row["kg_labels"].split("|"),
                                         key=len)
                    xaxis_labels.append(each_row["label_clean"] +
                                        " \n({})".format(longest_string))
                    for each_score_column in all_score_columns:
                        memo[each_score_column].append("{:.2f}".format(
                            each_row[each_score_column]))

            # add ground truth information
            xaxis_labels.append(each_group["label_clean"].iloc[0])
            for each_score_column in all_score_columns:
                memo[each_score_column].append("{:.2f}".format(
                    each_group[each_score_column].iloc[0]))
        # build figure
        bar = Bar()
        bar.add_xaxis(xaxis_labels)
        for k, v in memo.items():
            bar.add_yaxis(k, v)

        # set the global options
        bar.set_global_opts(
            title_opts=opts.TitleOpts(title=title, pos_left='40%'),
            legend_opts=opts.LegendOpts(pos_left="center",
                                        pos_top="bottom",
                                        orient='horizontal'),
            brush_opts=opts.BrushOpts(),
            toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(
                    title="save as image"),
                magic_type=opts.ToolBoxFeatureMagicTypeOpts(
                    line_title="switch to line chart",
                    bar_title="switch to bar chart",
                    stack_title="switch to stacked values",
                    tiled_title="switch to tiled values"),
                data_zoom=opts.ToolBoxFeatureDataZoomOpts(
                    zoom_title="zoom in", back_title="zoom reset"),
                restore=opts.ToolBoxFeatureRestoreOpts(title="reset"),
                data_view=opts.ToolBoxFeatureDataViewOpts(
                    title="Data table view",
                    lang=["Table view", "Close", "Refresh"],
                ),
                brush=opts.ToolBoxFeatureBrushOpts(
                    rect_title="rectangle choice",
                    polygon_title="polygon choice",
                    clear_title="clear choices",
                    keep_title="keep choices"))),
            datazoom_opts=opts.DataZoomOpts(orient="vertical"),
            # yaxis_opts=opts.AxisOpts(name='labels', name_gap=5000, name_rotate=15),
            tooltip_opts=opts.TooltipOpts(is_show=True,
                                          trigger="axis",
                                          axis_pointer_type="shadow"),
            xaxis_opts=opts.AxisOpts(axistick_opts=opts.AxisTickOpts(
                is_inside=True,
                length=850,
                linestyle_opts=opts.LineStyleOpts(type_="dotted",
                                                  opacity=0.5))))

        # do not shown bar label values
        bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))

        bar.reversal_axis()

        grid = (Grid(init_opts=opts.InitOpts(
            width="1500px",
            height="1000px",
            page_title="Table Linker visualization page")).add(
                bar,
                grid_opts=opts.GridOpts(pos_top='5%',
                                        pos_bottom="10%",
                                        pos_right='5%',
                                        pos_left="20%")))
        grid.render(output_path + ".html")
Exemple #16
0
                # 数据视图工具
                opts.ToolBoxFeatureDataViewOpts(
                    # 是否显示该工具
                    is_show=True,
                    # 提示语
                    title="数据视图",
                    # 是否不可编辑
                    is_read_only=False,
                ),

                # 缩放工具配置项,直角坐标系适用
                opts.ToolBoxFeatureDataZoomOpts(
                    # 是否显示该工具。
                    is_show=False,
                    # 提示语
                    zoom_title="区域缩放",
                    # 提示语
                    back_title="区域缩放还原",
                ),

                # 图表类型切换,适用于直角坐标系
                opts.ToolBoxFeatureMagicTypeOpts(
                    # 是否显示该工具
                    is_show=False,
                    # 启用的动态类型
                    type_=['stack', 'line', 'bar', 'tiled'],
                ),

                # 工具箱选框组件配置项
                opts.ToolBoxFeatureBrushOpts(
                    # 选择显示哪些选框
def draw_heat_map_picture(grid_data,
                          x_list,
                          max_number,
                          to_file,
                          svg_name,
                          height='1200px'):
    """
    grid堆叠热力图
    :param height:
    :param x_list: 横轴列表
    :param max_number: 最大值
    :param grid_data: [{}] key包括 series_name, y_name, sub_title, value
    :param to_file:
    :param svg_name:
    :return:
    """
    grid_number = len(grid_data)
    grid = (Grid(init_opts=opts.InitOpts(
        width="900px", height=height, bg_color='rgb(255, 255, 255)')))

    i = 0
    all_top = 5
    for grid_data_one in grid_data:
        # max_number_list = [i[2] for i in grid_data_one['value'][3:]]
        # max_number = max(max_number_list)
        length = int(len(grid_data_one['y_name'])) * 1.5
        top_position = all_top
        bottom_position = 100 - top_position - length
        all_top = top_position + length + 2
        # print(top_position)
        # print(bottom_position)
        # print(all_top)
        c = HeatMap() \
            .add_xaxis(x_list) \
            .add_yaxis(grid_data_one['series_name'], grid_data_one['y_name'], grid_data_one['value'],
                       label_opts=opts.LabelOpts(is_show=True, position="inside"),
                       )
        if i == grid_number - 1:
            c = c.set_global_opts(
                title_opts=opts.TitleOpts(
                    title="",
                    subtitle=grid_data_one['sub_title'],
                    pos_top=str(top_position) + "%",
                ),
                visualmap_opts=opts.VisualMapOpts(
                    is_show=False,
                    min_=0,
                    max_=max_number,
                    range_color=['#fff799', '#ae4130']),
                xaxis_opts=opts.AxisOpts(
                    is_show=True,
                    axislabel_opts=opts.LabelOpts(interval=0, rotate=30),
                    splitarea_opts=opts.SplitAreaOpts(
                        is_show=False,
                        areastyle_opts=opts.AreaStyleOpts(opacity=0))),
                yaxis_opts=opts.AxisOpts(
                    axislabel_opts=opts.LabelOpts(font_size=14, interval=0),
                    splitarea_opts=opts.SplitAreaOpts(
                        is_show=False,
                        areastyle_opts=opts.AreaStyleOpts(opacity=0))),
                legend_opts=opts.LegendOpts(pos_top="120%"),
                toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                    data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                    # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
                )),
            )
        else:
            c = c.set_global_opts(
                title_opts=opts.TitleOpts(
                    title="",
                    subtitle=grid_data_one['sub_title'],
                    pos_top=str(top_position - 2) + "%",
                ),
                visualmap_opts=opts.VisualMapOpts(
                    is_show=False,
                    min_=0,
                    max_=max_number,
                    range_color=['#fff799', '#ae4130']),
                xaxis_opts=opts.AxisOpts(
                    is_show=False,
                    splitarea_opts=opts.SplitAreaOpts(
                        is_show=False,
                        areastyle_opts=opts.AreaStyleOpts(opacity=0))),
                yaxis_opts=opts.AxisOpts(
                    axislabel_opts=opts.LabelOpts(font_size=14, interval=0),
                    splitarea_opts=opts.SplitAreaOpts(
                        is_show=False,
                        areastyle_opts=opts.AreaStyleOpts(opacity=0))),
                legend_opts=opts.LegendOpts(pos_top="120%"),
                toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts(
                    data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False),
                    # brush=opts.ToolBoxFeatureBrushOpts(is_show=False),
                )),
            )
        # 加到grid
        grid = grid.add(c,
                        grid_opts=opts.GridOpts(
                            pos_bottom=str(bottom_position) + "%",
                            pos_top=str(top_position) + "%",
                            pos_left="25%",
                            pos_right="10%"))
        i = i + 1

    make_snapshot(snapshot, grid.render(to_file), svg_name)  # 生成svg图片