示例#1
0
def test_boxplot_item_base(fake_writer):
    x_axis = ["expr1", "expr2"]
    v1 = [
        [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
        [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790],
    ]
    v2 = [
        [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
        [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
    ]
    c = Boxplot()

    series_a = [
        opts.BoxplotItem(name=x_axis[0], value=d) for d in c.prepare_data(v1)
    ]
    series_b = [
        opts.BoxplotItem(name=x_axis[1], value=d) for d in c.prepare_data(v2)
    ]

    c.add_xaxis(xaxis_data=x_axis).add_yaxis("A", series_a).add_yaxis(
        "B", series_b)
    c.render()
    _, content = fake_writer.call_args[0]
    assert_equal(c.theme, "white")
    assert_equal(c.renderer, "canvas")
示例#2
0
def paintBoxPlot(datadict, xtitle, ytitle, title):
    graph = Boxplot(init_opts=opts.InitOpts(page_title=title))
    graph.set_global_opts(
        title_opts=opts.TitleOpts(title=title),
        yaxis_opts=opts.AxisOpts(name='Accuracy')
    )

    graph.add_xaxis([xtitle])
    for key, value in sorted(datadict.items()):
        # 为了画图的标准性,小于5人的年级图片将不会被加入盒图
        if len(value) > 4:
            graph.add_yaxis(key, graph.prepare_data([value]))
    
    graph.render('buctoj2_boxplot.html')
示例#3
0
def test_boxpolt_base():
    v1 = [
        [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
        [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790],
    ]
    v2 = [
        [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
        [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
    ]
    c = Boxplot()
    c.add_xaxis(["expr1", "expr2"]).add_yaxis("A", c.prepare_data(v1)).add_yaxis(
        "B", c.prepare_data(v2)
    )
    assert c.theme == "white"
    assert c.renderer == "canvas"
    c.render("render.html")
def test_boxpolt_base(fake_writer):
    v1 = [
        [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
        [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790],
    ]
    v2 = [
        [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
        [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
    ]
    c = Boxplot()
    c.add_xaxis(["expr1", "expr2"]).add_yaxis("A",
                                              c.prepare_data(v1)).add_yaxis(
                                                  "B", c.prepare_data(v2))
    c.render()
    _, content = fake_writer.call_args[0]
    eq_(c.theme, "white")
    eq_(c.renderer, "canvas")
示例#5
0
    def salary(self):
        sql = 'SELECT workYear,replace(salary,\'k\',\'\') s FROM jobs group by workYear,salary order by workYear'
        results = self.query(sql)
        sum = {}
        for r in results:
            rs = r[1].split('-')
            a = sum.get(r[0], [])
            a.extend(rs)
            sum[r[0]] = a

        for k in sum:
            numbers = list(map(int, sum[k]))
            v = list(set(numbers))
            sum[k] = v

        print(list(sum.values()))

        c = Boxplot()
        c.add_xaxis(list(sum.keys()))
        c.add_yaxis("薪资与工作经验", c.prepare_data(list(sum.values())))
        c.set_global_opts(title_opts=opts.TitleOpts(title="薪资与工作经验"))
        c.render("拉勾薪资.html")
示例#6
0
dom1, dom2, dom3 = [], [], []

list1 = []
for date, AQI in zip(data['Date'], data['AQI']):
    year = date.split('-')[0]
    if year in ['2015', '2016']:
        dom1.append(AQI)
    elif year in ['2017', '2018']:
        dom2.append(AQI)
    elif year in ['2019', '2020']:
        dom3.append(AQI)

x = ['2015-2016年', '2017-2018年', '2019-2020年']
y = [dom1, dom2, dom3]

boxplot = Boxplot()

boxplot.add_xaxis(x)
boxplot.add_yaxis('Delhi', boxplot.prepare_data(y))

boxplot.set_global_opts(title_opts=opts.TitleOpts(
    title='2015-2020印度德里AQI箱型图',
    pos_left='center',
),
                        legend_opts=opts.LegendOpts(
                            pos_left='left',
                            orient='vertical',
                        ))

boxplot.render('boxplot_AQI.html')
示例#7
0
    slope = "{:0.2f}".format(slope)
    if slope <= str(0.1):
        list_5.append(df['height'][i])
    if str(0.1) < slope <= str(0.5):
        list_10.append(df['height'][i])
    if str(0.5) < slope <= str(0.9):
        list_15.append(df['height'][i])
    if str(0.9) < slope <= str(1.3):
        list_20.append(df['height'][i])
    if slope > str(1.3):
        list_30.append(df['height'][i])

sum_list = []
sum_list.append(list_5)
sum_list.append(list_10)
sum_list.append(list_15)
sum_list.append(list_20)
sum_list.append(list_30)

c = Boxplot()
c.add_xaxis(["0-0.1", "0.1-0.5", "0.5-0.9", "0.9-1.3", "1.3以上"])
c.add_yaxis("ATLAS Elevation-Airborne LiDAR Elevation(m)",
            c.prepare_data(sum_list))

c.set_global_opts(
    title_opts=opts.TitleOpts(title="All data"),
    xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True)),
    yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True)),
)
c.render("boxplot.html")
示例#8
0
from pyecharts import options as opts
from pyecharts.charts import Boxplot

v1 = [
    [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980],
    [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790],
]
v2 = [
    [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920],
    [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870],
]
c = Boxplot()
c.add_xaxis(["expr1", "expr2"])
c.add_yaxis("A", c.prepare_data(v1))
c.add_yaxis("B", c.prepare_data(v2))
c.set_global_opts(title_opts=opts.TitleOpts(title="BoxPlot-基本示例"))
c.render("boxplot_base.html")
示例#9
0
# 箱型图绘制
from pyecharts import options as opts
from pyecharts.charts import Boxplot

v1 = [
    list(look_support_money['看一看']),
    list(look_support_money['点赞']),
    list(look_support_money['赞赏'])
]

c = Boxplot(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE, chart_id=4))
c.add_xaxis(["看一看", "点赞", '赞赏'])
c.add_yaxis("", c.prepare_data(v1))
c.set_global_opts(title_opts=opts.TitleOpts(title="看一看,点赞,赞赏分布"))
c.render("../output/看一看,点赞,赞赏.html")
c.render_notebook()

# ## 文章类型占比

# In[95]:

kind = article['文章类型'].value_counts()

# 绘制玫瑰图
from pyecharts import options as opts
from pyecharts.charts import Pie

v = ['爬虫', '其他', '数据分析', '爬虫+数据分析', 'Python 脚本程序', '可视化', '爬虫+可视化']
c = (Pie(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE, chart_id=5)).add(
    "",
示例#10
0
list1 = []
for date, AQI in zip(data['Date'], data['PM2.5']):
    year = date.split('-')[0]
    if year in ['2015', '2016']:
        dom1.append(AQI)
    elif year in ['2017', '2018']:
        dom2.append(AQI)
    elif year in ['2019', '2020']:
        dom3.append(AQI)

x = ['2015-2016年', '2017-2018年', '2019-2020年']
y = [dom1, dom2, dom3]

boxplot = Boxplot()

boxplot.add_xaxis(x)
boxplot.add_yaxis('Delhi', boxplot.prepare_data(y))

boxplot.set_global_opts(
    title_opts=opts.TitleOpts(
        title='2015-2020印度德里PM2.5箱型图',
        pos_left='center',
    ),
    legend_opts=opts.LegendOpts(
        pos_left='left',
        orient='vertical',
    )
)

boxplot.render('boxplot_PM2.5.html')