コード例 #1
0
ファイル: featurn_ksh.py プロジェクト: yanHaowen/keshihua
def ksh_scatter(*data):
    n = len(data)

    if "FG" in data:
        m = 4

        lamble = 0  #数据是2D为0,3D为1
        if data[m] == "FG":
            scatter = pyecharts.Scatter(data[0])
            scatter.add(data[m - 3], data[m - 2], data[m - 1])

        else:
            scatter = pyecharts.Scatter3D(data[0], width=1200, height=600)
            scatter.add(data[m - 3],
                        data[m - 2],
                        is_visualmap=True,
                        visual_range_color=range_color)
            lamble = 1

        while m <= n:
            if lamble == 0:
                scatter.add(data[m - 3], data[m - 2], data[m - 1])
                m = m + 4
            else:
                print(m)
                scatter.add(data[m],
                            data[m + 1],
                            is_visualmap=True,
                            visual_range_color=range_color)
                m = m + 3

    if n == 4:
        scatter = pyecharts.Scatter(data[0])
        scatter.add(data[1], data[2], data[3])
    if n == 3:
        scatter = pyecharts.Scatter3D(data[0], width=1200, height=600)
        scatter.add(data[1],
                    data[2],
                    data[3],
                    data[4],
                    is_visualmap=True,
                    visual_range_color=range_color)
    return scatter
コード例 #2
0
ファイル: test_pyecharts.py プロジェクト: sxl47/learn
def func():

    page = pyecharts.Page()  # step 1

    # bar
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = pyecharts.Bar("柱状图数据堆叠示例")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True)
    page.add(bar)  # step 2

    # scatter3D
    import random
    data = [[
        random.randint(0, 100),
        random.randint(0, 100),
        random.randint(0, 100)
    ] for _ in range(80)]
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    scatter3D = pyecharts.Scatter3D("3D 散点图示例", width=1200, height=600)
    scatter3D.add("", data, is_visualmap=True, visual_range_color=range_color)
    page.add(scatter3D)  # step 2

    page.render()  # step 3

    # scatter_geo
    attr = ['11', '22']
    data = ['1', '2']
    scatter_geo = pyecharts.Geo("地理位置视图", width=1200, height=600)
    scatter_geo.add("", attr, data)
    page.add(scatter_geo)  # step 2

    page.render()  # step 3

    data = [["广州", "北京"], ["广州", "上海"]]
    scatter_geo = pyecharts.GeoLines("地理位置视图", width=1200, height=600)
    scatter_geo.add("上午航班",
                    data,
                    geo_normal_color='#ff00ff',
                    geo_effect_period=9,
                    geo_effect_color='#ff0000',
                    geo_effect_symbol='arrow')
    data = [["广州", "南昌"], ["广州", "成都"]]
    scatter_geo.add("下午航班",
                    data,
                    geo_effect_traillength=1,
                    geo_emphasis_color='#0000ff')
    page.add(scatter_geo)  # step 2

    page.render()  # step 3
コード例 #3
0
def creat_Scatter3D():
    data = [[
        random.randint(0, 100),
        random.randint(0, 100),
        random.randint(0, 100)
    ] for _ in range(80)]
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    scatter3D = pyecharts.Scatter3D("3D 散点图示例", width=1200, height=600)
    scatter3D.add("", data, is_visualmap=True, visual_range_color=range_color)
    page.add(scatter3D)
コード例 #4
0
def t12(pa):
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    scatter3D = p.Scatter3D("经验需求薪水")
    scatter3D.add("3D",
                  next(pa),
                  is_visualmap=True,
                  visual_range_color=range_color,
                  is_grid3d_rotate=True,
                  visual_range=[7000, 35000],
                  xaxis3d_name='经验',
                  yaxis3d_name='需求',
                  zaxis3d_name='薪水',
                  is_toolbox_show=False,
                  visual_top=9999)
    return scatter3D
コード例 #5
0
ファイル: 3_multiaxes.py プロジェクト: mr-why93/dash_tutorial
        bar.add("商家A", attr, v1, is_stack=True)
        bar.add("商家B", attr, v2, is_stack=True)
        page.add(bar)  # step 2

        # scatter3D
        import random

        data = [
            [random.randint(0, 100),
             random.randint(0, 100),
             random.randint(0, 100)] for _ in range(80)
        ]
        range_color = [
            '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
            '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
        scatter3D = echarts.Scatter3D("3D 散点图示例", width=1200, height=600)
        scatter3D.add("", data, is_visualmap=True, visual_range_color=range_color)
        page.add(scatter3D)  # step 2
        page.render(path='tmp/page.html')

    # 当然,更多图也是可以的
    if __name__ == '__main__':
        page = echarts.Page()

        # line
        attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        line = echarts.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"])
コード例 #6
0
    def draw(self):

        mat = Cluster.pivot.replace(np.nan, 0).as_matrix()
        cluster = KMeans(n_clusters=6).fit(mat)

        # clustering result
        Cluster.clusters = pd.DataFrame({
            Cluster.sampleCol: Cluster.pivot.index,
            'Cluster': cluster.labels_
        })

        # Cluster-Sample-Feature table: explore the meaning/constitution of a cluster
        ClSpFt = pd.merge(Cluster.SampFeat, Cluster.clusters,
                          how='left').groupby('Cluster')
        ForEachCluster = lambda x: x.pivot(
            index=Cluster.sampleCol, columns=Cluster.featureCol, values='Freq'
        ).apply(percent).replace(np.nan, 0)
        Cluster.ClSpFt = ClSpFt.apply(ForEachCluster)

        pca = skl.PCA(n_components=3).fit(mat)
        xyz = pca.transform(mat)
        #         xl,yl,zl=pca.explained_variance_ratio_

        # 3D scatter plot
        scatter = pch.Scatter3D('Clustering ' + Cluster.sampleCol + ' by ' +
                                Cluster.featureCol,
                                is_grid=True,
                                width=1200,
                                height=600)

        for i, group in pd.concat(
            [Cluster.clusters, pd.DataFrame(xyz)], axis=1).groupby('Cluster'):
            scatter.add('Cluster ' + str(i),
                        xyz[group.index].tolist(),
                        grid_right="75%",
                        legend_top="10%",
                        legend_pos="0%",
                        is_grid3D_rotate=True,
                        grid3D_rotate_speed=40)

        # Radar chart
        radar = pch.Radar('Radar Chart of ' + Cluster.sampleCol + ' on ' +
                          Cluster.featureCol,
                          is_grid=True)
        schema = [(feat, 1) for feat in Cluster.switch[Cluster.featureCol]]
        radar.config(schema)

        for i in np.arange(6):
            data = Cluster.ClSpFt.loc[i].as_matrix().tolist()
            c = [
                '#50a3ba', '#eac763', '#d94e5d', '#4e79a7', '#f9713c',
                '#b3e4a1'
            ]
            radar.add('Cluster ' + str(i),
                      data,
                      item_color=c[i],
                      legend_pos='0%',
                      legend_top="10%",
                      is_area_show=True,
                      area_color=c[i],
                      area_opacity=0.5)

        radar.render('Graph/Cluster/' + Cluster.sampleCol +
                     Cluster.featureCol + '_radar.html')

        scatter.render('Graph/Cluster/' + Cluster.sampleCol +
                       Cluster.featureCol + '_scatter.html')