def polar_flower() -> Polar:
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    c = (
        Polar()
        .add_schema(angleaxis_opts=opts.AngleAxisOpts(start_angle=0, min_=0))
        .add("flower", data, label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-Flower"))
    )
    return c
Example #2
0
def get_instance(request):
    # bar = Bar()
    # bar.add_xaxis(["A", "B", "C", "D", "E", "F"])
    # bar.add_yaxis("G", [5, 20, 36, 10, 75, 90])
    # bar.render()
    bar = (
        Polar()
        .add("", [(10, random.randint(1, 100)) for i in range(300)], type_="scatter")
        .add("", [(11, random.randint(1, 100)) for i in range(300)], type_="scatter")
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-Scatter1"))
    )
    return HttpResponse(bar.render_embed())
Example #3
0
def polar_love() -> Polar:
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    c = (Polar().add_schema(angleaxis_opts=opts.AngleAxisOpts(
        data=hour, type_="value", boundary_gap=False, start_angle=0)).add(
            "love", data,
            label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
                title_opts=opts.TitleOpts(title="Polar-Love")))
    return c
def polar_effectscatter() -> Polar:
    data = [(i, random.randint(1, 100)) for i in range(10)]
    c = (
        Polar()
        .add(
            "",
            data,
            type_="effectScatter",
            effect_opts=opts.EffectOpts(scale=10, period=5),
            label_opts=opts.LabelOpts(is_show=False),
        )
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-EffectScatter"))
    )
    return c
Example #5
0
def polar_scatter() -> Polar:
    data = []
    for i in range(1001):
        theta = i / 100 * 360
        r = random.randint(1, 100) * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])

    print(data)
    c = (
        Polar(init_opts=opts.InitOpts(width="1920px",
                                      height="960px",
                                      page_title="Graph-Global AS Core Map",
                                      theme=ThemeType.DARK)).
        add_schema(angleaxis_opts=opts.AngleAxisOpts(
            type_="value", boundary_gap=False, start_angle=0, min_=0,
            max_=360)).add(
                "",
                data,
                type_="scatter",
                # effect_opts=opts.EffectOpts(scale=10, period=5),
                symbol="arrow",
                label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
                    title_opts=opts.TitleOpts(title="Polar Map")))
    return c
Example #6
0
import random

from pyecharts import options as opts
from pyecharts.charts import Polar


data = [(i, random.randint(1, 100)) for i in range(10)]
c = (
    Polar()
    .add(
        "",
        data,
        type_="effectScatter",
        effect_opts=opts.EffectOpts(scale=10, period=5),
        label_opts=opts.LabelOpts(is_show=False),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="Polar-EffectScatter"))
    .render("polar_effectscatter.html")
)
Example #7
0
from pyecharts import options as opts
from pyecharts.charts import Polar
from pyecharts.faker import Faker

c = (
    Polar()
    .add_schema(
        radiusaxis_opts=opts.RadiusAxisOpts(data=Faker.week, type_="category"),
        angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True, max_=10),
    )
    .add("A", [1, 2, 3, 4, 3, 5, 1], type_="bar")
    .set_global_opts(title_opts=opts.TitleOpts(title="Polar-RadiusAxis"))
    .set_series_opts(label_opts=opts.LabelOpts(is_show=True))
    .render("Polar_radius.html")
)
Example #8
0
# from pyecharts import Polar

import random

from pyecharts.charts import Polar

data_1 = [(10, random.randint(1, 100)) for i in range(300)]

data_2 = [(11, random.randint(1, 100)) for i in range(300)]

polar = Polar()

polar.add(
    "",
    data_1,
)

polar.add(
    "",
    data_2,
)

polar.render("pyhtml_生成的散点图.html")
Example #9
0
import math
import pyecharts.options as opts
from pyecharts.charts import Polar
"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://www.echartsjs.com/examples/editor.html?c=line-polar
目前无法实现的功能:
1、赞无
"""

data = []

for i in range(0, 101):
    theta = i / 100 * 360
    r = 5 * (1 + math.sin(theta / 180 * math.pi))
    data.append([r, theta])

(Polar(init_opts=opts.InitOpts(width="1600px", height="800px")).add(
    series_name="line", data=data, label_opts=opts.LabelOpts(
        is_show=False)).add_schema(angleaxis_opts=opts.AngleAxisOpts(
            start_angle=0, type_="value", is_clockwise=True)).set_global_opts(
                tooltip_opts=opts.TooltipOpts(trigger="axis",
                                              axis_pointer_type="cross"),
                title_opts=opts.TitleOpts(title="极坐标双数值轴"),
            ).render("render/two_value_axes_in_polar.html"))
Example #10
0
from pyecharts import options as opts
from pyecharts.charts import Polar
from pyecharts.faker import Faker

c = (Polar().add_schema(
    angleaxis_opts=opts.AngleAxisOpts(data=Faker.week, type_="category")).add(
        "A", [1, 2, 3, 4, 3, 5, 1], type_="bar", stack="stack0").add(
            "B", [2, 4, 6, 1, 2, 3, 1], type_="bar", stack="stack0").add(
                "C", [1, 2, 3, 4, 1, 2, 5], type_="bar",
                stack="stack0").set_global_opts(title_opts=opts.TitleOpts(
                    title="Polar-AngleAxis")).render("Polar_angleaxis.html"))
Example #11
0
    data,
).set_global_opts(title_opts=opts.TitleOpts(
    title="Parallel-Category")).render("parallel_category.html"))

# Section3 极坐标系
# 爱心图
import math
from pyecharts.charts import Polar
data = []
for i in range(101):
    theta = i / 100 * 360
    r = 5 * (1 + math.sin(theta / 180 * math.pi))
    data.append([r, theta])
hour = [i for i in range(1, 15)]
c = (Polar().add_schema(angleaxis_opts=opts.AngleAxisOpts(start_angle=0)).add(
    "love", data, label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
        title_opts=opts.TitleOpts(
            title="Polar-Love")).render("polar_love.html"))

# 水溅的效果
import random
data = [(i, random.randint(1, 100)) for i in range(10)]
c = (Polar().add(
    "",
    data,
    type_="effectScatter",
    effect_opts=opts.EffectOpts(scale=10, period=5),
    label_opts=opts.LabelOpts(is_show=False),
).set_global_opts(title_opts=opts.TitleOpts(
    title="Polar-EffectScatter")).render("polar_effectscatter.html"))

# Section4 雷达图
Example #12
0
目前无法实现的功能:

1、赞无
"""

data = []

for i in range(0, 101):
    theta = i / 100 * 360
    r = 5 * (1 + math.sin(theta / 180 * math.pi))
    data.append([r, theta])

c = (
    Polar()
    .add(series_name="line", data=data, label_opts=opts.LabelOpts(is_show=False))
    .add_schema(
        angleaxis_opts=opts.AngleAxisOpts(
            start_angle=0, type_="value", is_clockwise=True
        )
    )
    .set_global_opts(
        tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
        title_opts=opts.TitleOpts(title="极坐标双数值轴"),
    )
    
)

c.width = "100%"
put_html(c.render_notebook())
import random

from pyecharts import options as opts
from pyecharts.charts import Polar

data = [(i, random.randint(1, 100)) for i in range(101)]
c = (Polar().add(
    "", data, type_="scatter", label_opts=opts.LabelOpts(
        is_show=False)).set_global_opts(title_opts=opts.TitleOpts(
            title="Polar-Scatter0")).render("Polar_scatter_0.html"))
from pywebio.output import put_html
import random

from pyecharts import options as opts
from pyecharts.charts import Polar

c = (Polar().add(
    "", [(10, random.randint(1, 100)) for i in range(300)],
    type_="scatter").add(
        "", [(11, random.randint(1, 100)) for i in range(300)],
        type_="scatter").set_series_opts(label_opts=opts.LabelOpts(
            is_show=False)).set_global_opts(title_opts=opts.TitleOpts(
                title="Polar-Scatter1")))

c.width = "100%"
put_html(c.render_notebook())
Example #15
0
def pyecharts():
    from pyecharts.charts import Bar
    from pyecharts.faker import Faker
    from pyecharts import options as opts
    from pyecharts.charts import Polar
    from pyecharts.charts import HeatMap
    from pyecharts.charts import Tree

    r1 = ['草莓', '芒果', '葡萄', '雪梨', '西瓜', '柠檬', '车厘子']
    r2 = [127, 33, 110, 29, 146, 121, 36]
    r3 = [25, 87, 114, 131, 130, 94, 146]
    c1 = (Bar({
        "width": "100%"
    }).add_xaxis(r1).add_yaxis("商家A", r2).add_yaxis("商家B", r3).set_global_opts(
        title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题")))

    c2 = (Polar({
        "width": "100%"
    }).add_schema(
        radiusaxis_opts=opts.RadiusAxisOpts(data=Faker.week, type_="category"),
        angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True, max_=10),
    ).add("A", [1, 2, 3, 4, 3, 5, 1], type_="bar").set_global_opts(
        title_opts=opts.TitleOpts(title="Polar-RadiusAxis")).set_series_opts(
            label_opts=opts.LabelOpts(is_show=True)))

    data = [{
        "children": [
            {
                "name": "B"
            },
            {
                "children": [{
                    "children": [{
                        "name": "I"
                    }],
                    "name": "E"
                }, {
                    "name": "F"
                }],
                "name":
                "C",
            },
            {
                "children": [
                    {
                        "children": [{
                            "name": "J"
                        }, {
                            "name": "K"
                        }],
                        "name": "G"
                    },
                    {
                        "name": "H"
                    },
                ],
                "name":
                "D",
            },
        ],
        "name":
        "A",
    }]

    c3 = (Tree({
        "width": "100%"
    }).add("",
           data).set_global_opts(title_opts=opts.TitleOpts(title="Tree-基本示例")))

    value = [[i, j, int(i * j * 3.14 * 314 % 50)] for i in range(24)
             for j in range(7)]
    c4 = (HeatMap({
        "width": "100%"
    }).add_xaxis(Faker.clock).add_yaxis(
        "series0",
        Faker.week,
        value,
        label_opts=opts.LabelOpts(is_show=True, position="inside"),
    ).set_global_opts(
        title_opts=opts.TitleOpts(title="HeatMap-Label 显示"),
        visualmap_opts=opts.VisualMapOpts(),
    ))

    put_grid([[put_html(c1.render_notebook()),
               put_html(c2.render_notebook())],
              [put_html(c3.render_notebook()),
               put_html(c4.render_notebook())]],
             cell_width='1fr',
             cell_height='1fr')
Example #16
0
def show_pyecharts():

    x_data = [
        '0.0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9',
        '1.0'
    ]
    y_data = [
        '1533', '573', '502', '491', '520', '556', '577', '788', '1252',
        '20564', '6393'
    ]

    #情感分析柱状图
    bar = (Bar().add_xaxis(x_data).add_yaxis(
        "情感分析",
        y_data,
        label_opts=opts.LabelOpts(is_show=False),
        color='#3498DB').set_global_opts(title_opts={
            "text": "台海舆论情感分析",
            "subtext": "大于0.5为正面评价,小于0.5为负面评价"
        }))

    #台湾网饼图
    x_data2 = [
        "文化", "经贸", "媒体专栏", "网友专栏", "两岸专家", "两岸", "台商", "部委", "台海时事", "网友快言",
        "海峡时评", "两岸快评"
    ]
    y_data2 = [553, 553, 35, 39, 448, 465, 553, 321, 553, 406, 553, 556]

    pie = (Pie(init_opts=opts.InitOpts(theme=ThemeType.CHALK)).add(
        series_name="中国台湾网",
        data_pair=[list(z) for z in zip(x_data2, y_data2)],
        radius=["50%", "70%"],
        label_opts=opts.LabelOpts(is_show=False, position="center"),
    ).set_colors([
        "#E8F8F5", "#D1F2EB", "#A3E4D7", "#76D7C4", "#48C9B0", "#1ABC9C",
        "#17A589", "#148F77", "#117864", "#0E6251F", "#73C6B6", "#45B39D"
    ]).set_global_opts(legend_opts=opts.LegendOpts(
        pos_left="legft", orient="vertical")).set_series_opts(
            tooltip_opts=opts.TooltipOpts(
                trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"), ))

    #词云图
    word = (WordCloud().add(
        "",
        list1,
        word_size_range=[20, 100],
        shape=SymbolType.DIAMOND,
        textstyle_opts=opts.TextStyleOpts(font_family="cursive"),
    ))

    #折线图1
    y2[0], y2[1], y2[2] = None, None, None
    y4[1] = None
    line = (Line().add_xaxis(xaxis_data=x1).add_yaxis(
        series_name="微博",
        symbol="emptyCircle",
        is_symbol_show=True,
        color="#F2D7D5",
        y_axis=y1,
        label_opts=opts.LabelOpts(is_show=False),
        linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
            series_name="环球网",
            symbol="emptyCircle",
            is_symbol_show=True,
            color="#C0392B",
            y_axis=y2,
            label_opts=opts.LabelOpts(is_show=False),
            linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                series_name="中国台湾网",
                symbol="emptyCircle",
                is_symbol_show=True,
                color="#641E16",
                y_axis=y3,
                label_opts=opts.LabelOpts(is_show=False),
                linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                    series_name="知乎",
                    symbol="emptyCircle",
                    is_symbol_show=True,
                    color="#9B59B6",
                    y_axis=y4,
                    label_opts=opts.LabelOpts(is_show=False),
                    linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                        series_name="中国日报网",
                        symbol="emptyCircle",
                        is_symbol_show=True,
                        color="#512E5F",
                        y_axis=y5,
                        label_opts=opts.LabelOpts(is_show=False),
                        linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                            series_name="中新网",
                            symbol="emptyCircle",
                            is_symbol_show=True,
                            color="#2980B9",
                            y_axis=y6,
                            label_opts=opts.LabelOpts(is_show=False),
                            linestyle_opts=opts.LineStyleOpts(width=3)).
            add_yaxis(
                series_name="今日头条",
                symbol="emptyCircle",
                is_symbol_show=True,
                color="#154360",
                y_axis=y7,
                label_opts=opts.LabelOpts(is_show=False),
                linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                    series_name="光明网",
                    symbol="emptyCircle",
                    is_symbol_show=True,
                    color="#3498DB",
                    y_axis=y8,
                    label_opts=opts.LabelOpts(is_show=False),
                    linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                        series_name="凤凰网",
                        symbol="emptyCircle",
                        is_symbol_show=True,
                        color="#1ABC9C",
                        y_axis=y9,
                        label_opts=opts.LabelOpts(is_show=False),
                        linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
                            series_name="新华网",
                            symbol="emptyCircle",
                            is_symbol_show=True,
                            color="#0E6251",
                            y_axis=y10,
                            label_opts=opts.LabelOpts(is_show=False),
                            linestyle_opts=opts.LineStyleOpts(
                                width=3)).set_global_opts(
                                    tooltip_opts=opts.TooltipOpts(
                                        trigger="axis"),
                                    yaxis_opts=opts.AxisOpts(
                                        type_="value",
                                        axistick_opts=opts.AxisTickOpts(
                                            is_show=True),
                                        splitline_opts=opts.SplitLineOpts(
                                            is_show=True),
                                    ),
                                    xaxis_opts=opts.AxisOpts(
                                        type_="category",
                                        boundary_gap=False,
                                        axisline_opts=opts.AxisLineOpts(
                                            is_on_zero=False,
                                            linestyle_opts=opts.LineStyleOpts(
                                                color="#d14a61"))),
                                ))

    #平台占比饼图
    x_data3 = [
        "微博", "知乎", "中国台湾网", "环球网", "日报网", "中新网", "今日头条", "光明网", "凤凰网", "新华网"
    ]
    y_data3 = [5401, 157, 5035, 3245, 4296, 5574, 1891, 3131, 1052, 1997]
    data_pair = [list(z) for z in zip(x_data3, y_data3)]
    data_pair.sort(key=lambda x: x[1])

    pie2 = (Pie(init_opts=opts.InitOpts(theme=ThemeType.ROMA)).add(
        series_name="访问来源",
        data_pair=data_pair,
        rosetype="radius",
        radius="55%",
        center=["50%", "50%"],
        label_opts=opts.LabelOpts(is_show=False, position="center"),
    ).set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{d}%")))

    #折线图2
    line2 = (Line().add_xaxis(xaxis_data=x_data4).add_yaxis(
        series_name="热度走势",
        y_axis=y_data4,
        color="#FF69B4",
        markpoint_opts=opts.MarkPointOpts(
            data=[opts.MarkPointItem(type_="max")]),
        symbol="emptyCircle",
        is_symbol_show=True,
        is_smooth=True,
        label_opts=opts.LabelOpts(is_show=True),
    ).set_global_opts(
        tooltip_opts=opts.TooltipOpts(is_show=False),
        yaxis_opts=opts.AxisOpts(
            type_="value",
            axistick_opts=opts.AxisTickOpts(is_show=True),
            splitline_opts=opts.SplitLineOpts(is_show=True),
        ),
        xaxis_opts=opts.AxisOpts(type_="category",
                                 boundary_gap=False,
                                 axislabel_opts=opts.LabelOpts(rotate=45)),
    ))

    #条形图
    line3 = (Bar().add_xaxis(x_data5).add_yaxis(
        "平均值",
        y_data5,
        label_opts=opts.LabelOpts(is_show=False),
        color='#6A5ACD').reversal_axis().extend_axis(yaxis=opts.AxisOpts(
            type_='value',
            name='转发次数',
            position='left',
        )).set_global_opts(
            title_opts={"text": "评论与转发关系图"},
            xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
                formatter='{value}(评论数量)')),
        ))

    #圆
    radius = (Polar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)).add_schema(
        radiusaxis_opts=opts.RadiusAxisOpts(data=x_data6, type_="category"),
        angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True, max_=100000),
    ).add("点赞数量", y_data6, type_="bar").set_global_opts(
        title_opts=opts.TitleOpts(title="")).set_series_opts(
            label_opts=opts.LabelOpts(is_show=True)))

    return render_template("index2.html",
                           bar_data=bar.dump_options(),
                           word_data=word.dump_options(),
                           pie_data=pie.dump_options(),
                           pie2_data=pie2.dump_options(),
                           line_data=line.dump_options(),
                           line2_data=line2.dump_options(),
                           line3_data=line3.dump_options(),
                           radius_data=radius.dump_options())
import math

from pyecharts import options as opts
from pyecharts.charts import Polar

data = []
for i in range(361):
    t = i / 180 * math.pi
    r = math.sin(2 * t) * math.cos(2 * t)
    data.append([r, i])
c = (
    Polar()
    .add_schema(angleaxis_opts=opts.AngleAxisOpts(start_angle=0, min_=0))
    .add("flower", data, label_opts=opts.LabelOpts(is_show=False))
    .set_global_opts(title_opts=opts.TitleOpts(title="Polar-Flower"))
    .render("Polar_flower.html")
)
1、赞无
"""

data = []

for i in range(0, 360 + 1):
    t = i / 180 * math.pi
    r = math.sin(2 * t) * math.cos(2 * t)
    data.append([r, i])

(
    Polar()
    .add(
        series_name="line",
        data=data,
        label_opts=opts.LabelOpts(is_show=False),
        symbol_size=0,
    )
    .add_schema(
        angleaxis_opts=opts.AngleAxisOpts(
            start_angle=0, type_="value", is_clockwise=True
        ),
        radiusaxis_opts=opts.RadiusAxisOpts(min_=0),
    )
    .set_global_opts(
        tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
        title_opts=opts.TitleOpts(title="极坐标双数值轴"),
    )
    .render("two_value_axes_in_polar_2.html")
)
import math

from pyecharts import options as opts
from pyecharts.charts import Polar

data = []
for i in range(101):
    theta = i / 100 * 360
    r = 5 * (1 + math.sin(theta / 180 * math.pi))
    data.append([r, theta])
hour = [i for i in range(1, 25)]
c = (Polar().add_schema(angleaxis_opts=opts.AngleAxisOpts(
    data=hour, type_="value", boundary_gap=False, start_angle=0)).add(
        "love", data, label_opts=opts.LabelOpts(
            is_show=False)).set_global_opts(title_opts=opts.TitleOpts(
                title="Polar-Love")).render("polar_love.html"))
def polarChart(df):
     type_of_plot = st.selectbox("Select Type of Plot",["POLAR1","POLAR2","POLAR3 Angle"])
     all_columns = df.columns
    
        
        #st.success("Generating Customizable Plot of {} for {}".format(type_of_plot))
        
     if type_of_plot == 'POLAR1':
           
            columns_to_plot = st.selectbox("Select 1 column",all_columns,key='a' )
            
            columns_to_plot1 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot]], key='b' )
        # columns_to_plot2 = st.selectbox("Select 1 column",all_columns, key='c' )
            n = df[[columns_to_plot, columns_to_plot1]].sort_values(by = columns_to_plot1 , ascending = True)
            cje = n[columns_to_plot].tolist()
            other_var = n[columns_to_plot1].tolist()
          
           
            # cje = df[columns_to_plot].tolist()
            # other_var = df[columns_to_plot1].sort_values(ascending = True).tolist()
        # other_var1 = df[columns_to_plot2].tolist()
            polar = Polar()
            polar.add_schema( 
       radiusaxis_opts=opts.RadiusAxisOpts( data = cje ,type_="category",
                                                splitline_opts=opts.SplitLineOpts(is_show=False),
                                                axisline_opts=opts.AxisLineOpts(is_show=False),
                                                axistick_opts=opts.AxisTickOpts(is_show=False)),
            angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True,
                                              splitline_opts=opts.SplitLineOpts(is_show=False),
                                              axisline_opts=opts.AxisLineOpts(is_show=False),
                                              axislabel_opts=opts.LabelOpts(is_show=False),
                                              axistick_opts=opts.AxisTickOpts(is_show=False)))
            polar.add(columns_to_plot1, other_var, type_="bar")
            polar.set_global_opts(toolbox_opts=opts.ToolboxOpts())
            polar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='inside', font_size=8,
                                                            font_weight='bold'))
                             
            return polar
        
        
        
     if type_of_plot == 'POLAR2':
            columns_to_plot = st.selectbox("Select 1 column",all_columns,key='a' )
            columns_to_plot1 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot]], key='b' )
            columns_to_plot2 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot]], key='c' )
            columns_to_plot3 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot2,columns_to_plot]], key='c' )
            columns_to_plot4 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot2,columns_to_plot, columns_to_plot3]], key='c' )
            n = df[[columns_to_plot, columns_to_plot1, columns_to_plot2, columns_to_plot3, columns_to_plot4]].sort_values(by = columns_to_plot1 , ascending = True)
            
            cje = n[columns_to_plot].tolist()
            other_var = n[columns_to_plot1].tolist()
            other_var2 = n[columns_to_plot2].tolist()
            other_var3 = n[columns_to_plot3].tolist()
            other_var4 = n[columns_to_plot4].tolist()
          

            polar = Polar()
            polar.add_schema( 
       radiusaxis_opts=opts.RadiusAxisOpts( data = cje ,type_= "category",
                                                splitline_opts=opts.SplitLineOpts(is_show=False),
                                                axisline_opts=opts.AxisLineOpts(is_show=False),
                                                axistick_opts=opts.AxisTickOpts(is_show=False)),
            angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True,
                                              splitline_opts=opts.SplitLineOpts(is_show=False),
                                              axisline_opts=opts.AxisLineOpts(is_show=False),
                                              axislabel_opts=opts.LabelOpts(is_show=False),
                                              axistick_opts=opts.AxisTickOpts(is_show=False)))
            polar.add(columns_to_plot1, other_var, type_="bar" )
            polar.add(columns_to_plot2, other_var2, type_="bar")
            polar.add(columns_to_plot3, other_var3, type_="bar")
            polar.add(columns_to_plot4, other_var4, type_="bar")
            polar.set_global_opts(toolbox_opts=opts.ToolboxOpts(),)
            polar.set_series_opts(label_opts=opts.LabelOpts(is_show=True))
       
            return polar
        
     if type_of_plot == 'POLAR3 Angle':
            columns_to_plot = st.selectbox("Select 1 column",all_columns,key='a' )
            columns_to_plot1 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot]], key='b' )
            columns_to_plot2 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot]], key='c' )
            columns_to_plot3 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot2,columns_to_plot]], key='c' )
            columns_to_plot4 = st.selectbox("Select 1 column",[col for col in df.columns if col not in [columns_to_plot1, columns_to_plot2,columns_to_plot, columns_to_plot3]], key='c' )
            n = df[[columns_to_plot, columns_to_plot1, columns_to_plot2, columns_to_plot3, columns_to_plot4]].sort_values(by = columns_to_plot1 , ascending = True)
            
            cje = n[columns_to_plot].tolist()
            other_var = n[columns_to_plot1].tolist()
            other_var2 = n[columns_to_plot2].tolist()
            other_var3 = n[columns_to_plot3].tolist()
            other_var4 = n[columns_to_plot4].tolist()
          

            polar = Polar()
            polar.add_schema( 
    #    radiusaxis_opts=opts.RadiusAxisOpts( data = cje ,type_= "category",
    #                                             splitline_opts=opts.SplitLineOpts(is_show=False),
    #                                             axisline_opts=opts.AxisLineOpts(is_show=False),
    #                                             axistick_opts=opts.AxisTickOpts(is_show=False)),
            angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True,type_= "category",
                                              splitline_opts=opts.SplitLineOpts(is_show=False),
                                              axisline_opts=opts.AxisLineOpts(is_show=False),
                                              axislabel_opts=opts.LabelOpts(is_show=False),
                                              axistick_opts=opts.AxisTickOpts(is_show=False)))
            polar.add(columns_to_plot1, other_var, type_="bar", stack="stack0" )
            polar.add(columns_to_plot2, other_var2, type_="bar" , stack="stack0")
            polar.add(columns_to_plot3, other_var3, type_="bar" , stack="stack0")
            polar.add(columns_to_plot4, other_var4, type_="bar" , stack="stack0")
            polar.set_global_opts(toolbox_opts=opts.ToolboxOpts())
            polar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
       
            return polar
Example #21
0
polar = (Polar().add_schema(radiusaxis_opts=opts.RadiusAxisOpts(
    data=[2019, 2018, 2017], type_="category")).add(
        "清华大学", ranking[0], type_="bar", stack="stack0").add(
            "浙江大学", ranking[1], type_="bar",
            stack="stack0").add("北京大学",
                                ranking[2],
                                type_="bar",
                                stack="stack0").add(
                                    "华中科技大学",
                                    ranking[3],
                                    type_="bar",
                                    stack="stack0").add(
                                        "国防科技大学",
                                        ranking[4],
                                        type_="bar",
                                        stack="stack0").add(
                                            "上海交通大学",
                                            ranking[5],
                                            type_="bar",
                                            stack="stack0").add(
                                                "哈尔滨工业大学",
                                                ranking[6],
                                                type_="bar",
                                                stack="stack0").add(
                                                    "北京航空航天大学",
                                                    ranking[7],
                                                    type_="bar",
                                                    stack="stack0").add(
                                                        "西安电子科技大学",
                                                        ranking[8],
                                                        type_="bar",
                                                        stack="stack0").
         add("电子科技大学", ranking[9], type_="bar",
             stack="stack0").set_global_opts(
                 title_opts=opts.TitleOpts(title="最近三年计算机科学与技术高校排名变化情况",
                                           subtitle="从外圈到内圈依次为2017,2018,2019"),
                 legend_opts=opts.LegendOpts(pos_left="80%",
                                             orient="vertical")))
Example #22
0
# 计算数据的最大、最小、中位、四分位数
dt1 = boxplot.prepare_data(list(zip(*[Faker.values() for i in range(20)])))
dt2 = boxplot.prepare_data(list(zip(*[Faker.values() for i in range(20)])))
boxplot.add_yaxis("cat1", dt1)
boxplot.add_yaxis("cat2", dt2)
boxplot.render_notebook()

# %% [markdown]
# ### Polar -- 极坐标

import math
data=[]
# 生成数据,满足格式`[r, \theta]`,即可以认为角度为自变量、径向为因变量
for i in range(0, 360):
    data.append([100 * math.sin(i/180 * math.pi), i])
polar = Polar()
polar.add("", data)
# 调整角度坐标轴样式
polar.add_schema(
    angleaxis_opts=opts.AngleAxisOpts(
        interval=90,
        max_=360
    )
)
polar.render_notebook()

# %% [markdown]
# #### 极坐标柱状图

polar = Polar()
polar.add("", list(zip(Faker.choose(), Faker.values())), type_="bar")