本文整理汇总了Python中pyecharts.Bar类的典型用法代码示例。如果您正苦于以下问题:Python Bar类的具体用法?Python Bar怎么用?Python Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_grid_four_direction
def test_grid_four_direction():
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图示例", height=720, width=1200, title_pos="65%")
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True, legend_pos="80%")
line = Line("折线图示例")
line.add("最高气温", WEEK, [11, 11, 15, 13, 12, 13, 10],
mark_point=["max", "min"], mark_line=["average"])
line.add("最低气温", WEEK, [1, -2, 2, 5, 3, 2, 0],
mark_point=["max", "min"], mark_line=["average"],
legend_pos="20%")
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")
es = EffectScatter("动态散点图示例", title_top="50%")
es.add("es", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
effect_scale=6, legend_top="50%", legend_pos="20%")
grid = Grid()
grid.add(bar, grid_bottom="60%", grid_left="60%")
grid.add(line, grid_bottom="60%", grid_right="60%")
grid.add(scatter, grid_top="60%", grid_left="60%")
grid.add(es, grid_top="60%", grid_right="60%")
grid.render()
开发者ID:chumingke,项目名称:pyecharts,代码行数:26,代码来源:test_grid.py
示例2: test_numpy_array
def test_numpy_array():
v1 = np.array([5, 20, 36, 10, 75, 90])
bar = Bar(TITLE)
bar.add("商家A", CLOTHES, v1, is_stack=True)
html = bar.render_embed()
json_encoded_title = json.dumps(TITLE)
assert json_encoded_title in html
开发者ID:MandyCh,项目名称:pyecharts,代码行数:7,代码来源:test_base.py
示例3: ax_draw_macd
def ax_draw_macd(axes, kdata, n1=12, n2=26, n3=9):
"""绘制MACD
:param axes: 指定的坐标轴
:param KData kdata: KData
:param int n1: 指标 MACD 的参数1
:param int n2: 指标 MACD 的参数2
:param int n3: 指标 MACD 的参数3
"""
macd = MACD(CLOSE(kdata), n1, n2, n3)
bmacd, fmacd, smacd = macd.getResult(0), macd.getResult(1), macd.getResult(2)
text = 'MACD(%s,%s,%s) DIF:%.2f, DEA:%.2f, BAR:%.2f'%(n1,n2,n3,fmacd[-1],smacd[-1],bmacd[-1])
#axes.text(0.01,0.97, text, horizontalalignment='left', verticalalignment='top', transform=axes.transAxes)
total = len(kdata)
x_list = [i for i in range(total)]
y1_list = [round(x) if x > 0 else '-' for x in bmacd]
y2_list = [round(x) if x <= 0 else '-' for x in bmacd]
style = gcf().get_style(axes)
bar = Bar(subtitle=text, title_pos='10%', title_top='8%')
bar.add('1', x_list, y1_list, is_stack=True, is_legend_show=False, **style)
bar.add('2', x_list, y2_list, is_stack=True, is_legend_show=False, **style)
axes.add(bar)
fmacd.plot(axes=axes, line_type='dotted')
smacd.plot(axes=axes)
gcf().add_axis(axes)
return gcf()
开发者ID:fasiondog,项目名称:hikyuu,代码行数:30,代码来源:echart_draw.py
示例4: create_three
def create_three():
page = Page(page_title=TEST_PAGE_TITLE)
# bar
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
page.add(bar)
# scatter3D
import random
data = [
[random.randint(0, 100),
random.randint(0, 100),
random.randint(0, 100)] for _ in range(80)
]
scatter3d = Scatter3D("3D 散点图示例", width=1200, height=600)
scatter3d.add("", data, is_visualmap=True, visual_range_color=RANGE_COLOR)
page.add(scatter3d)
# guangdong
value = [20, 190, 253, 77, 65]
attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市']
map = Map("广东地图示例", width=1200, height=600)
map.add("", attr, value, maptype='广东', is_visualmap=True,
visual_text_color='#000')
page.add(map)
return page
开发者ID:chumingke,项目名称:pyecharts,代码行数:31,代码来源:test_page.py
示例5: test_grid_top_bottom
def test_grid_top_bottom():
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图示例", height=720)
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
line = Line("折线图示例", title_top="50%")
line.add(
"最高气温",
WEEK,
[11, 11, 15, 13, 12, 13, 10],
mark_point=["max", "min"],
mark_line=["average"],
)
line.add(
"最低气温",
WEEK,
[1, -2, 2, 5, 3, 2, 0],
mark_point=["max", "min"],
mark_line=["average"],
legend_top="50%",
)
grid = Grid()
grid.add(bar, grid_bottom="60%")
grid.add(line, grid_top="60%")
grid.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:27,代码来源:test_grid.py
示例6: create_a_bar
def create_a_bar(title):
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar(title)
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
return bar
开发者ID:Jesszen,项目名称:pyecharts,代码行数:7,代码来源:test_notebook.py
示例7: test_grid_properties
def test_grid_properties():
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图示例", height=720)
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
line = Line("折线图示例", title_top="50%")
line.add(
"最高气温",
WEEK,
[11, 11, 15, 13, 12, 13, 10],
mark_point=["max", "min"],
mark_line=["average"],
)
line.add(
"最低气温",
WEEK,
[1, -2, 2, 5, 3, 2, 0],
mark_point=["max", "min"],
mark_line=["average"],
legend_top="50%",
)
grid = Grid(width=1024, height=768)
grid.add(bar, grid_bottom="60%")
grid.add(line, grid_top="60%")
eq_(grid.width, 1024)
eq_(grid.height, 768)
assert (
("echarts" in bar.js_dependencies)
or ("echarts.min" in bar.js_dependencies)
)
开发者ID:Jesszen,项目名称:pyecharts,代码行数:32,代码来源:test_chart_properties.py
示例8: test_bar_stack
def test_bar_stack():
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", CLOTHES, clothes_v1, is_stack=True)
bar.add("商家B", CLOTHES, clothes_v2, is_stack=True)
html_content = bar._repr_html_()
assert "dataZoom" not in html_content
assert "stack_" in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:7,代码来源:test_bar.py
示例9: test_bar_rotate_label
def test_bar_rotate_label():
days = ["{}天".format(i) for i in range(20)]
days_v1 = [random.randint(1, 20) for _ in range(20)]
bar = Bar("坐标轴标签旋转示例")
bar.add("", days, days_v1, xaxis_interval=0, xaxis_rotate=30,
yaxis_rotate=30)
assert "stack_" not in bar._repr_html_()
开发者ID:chumingke,项目名称:pyecharts,代码行数:7,代码来源:test_bar.py
示例10: test_grid_add_overlap
def test_grid_add_overlap():
from pyecharts import Overlap
grid = Grid()
attr = ["{}月".format(i) for i in range(1, 13)]
v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
v3 = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
bar = Bar("Overlap+Grid 示例", width=1200, height=600, title_pos="40%")
bar.add("蒸发量", attr, v1)
bar.add(
"降水量",
attr,
v2,
yaxis_formatter=" ml",
yaxis_max=250,
legend_pos="85%",
legend_orient="vertical",
legend_top="45%",
)
line = Line()
line.add("平均温度", attr, v3, yaxis_formatter=" °C")
overlap = Overlap()
overlap.add(bar)
overlap.add(line, is_add_yaxis=True, yaxis_index=1)
grid.add(overlap, grid_right="20%")
grid.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:32,代码来源:test_grid.py
示例11: test_bar_datazoom_undefined
def test_bar_datazoom_undefined():
days = ["{}天".format(i) for i in range(30)]
days_v1 = [random.randint(1, 30) for _ in range(30)]
bar = Bar("Bar - datazoom 默认 示例")
bar.add("", days, days_v1, is_label_show=True, is_datazoom_show=True)
html_content = bar._repr_html_()
assert "dataZoom" in html_content
assert ': "slider"' in html_content
assert ': "inside"' not in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:9,代码来源:test_bar.py
示例12: create_demo_bar
def create_demo_bar(chart_id_demo=None):
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True)
if chart_id_demo:
bar._chart_id = chart_id_demo
return bar
开发者ID:MandyCh,项目名称:pyecharts,代码行数:10,代码来源:test_template_function.py
示例13: test_bar_datazoom_inside
def test_bar_datazoom_inside():
days = ["{}天".format(i) for i in range(30)]
days_v1 = [random.randint(1, 30) for _ in range(30)]
bar = Bar("Bar - datazoom - inside 示例")
bar.add("", days, days_v1, is_datazoom_show=True,
datazoom_type='inside', datazoom_range=[10, 25])
html_content = bar._repr_html_()
assert "dataZoom" in html_content
assert ': "inside"' in html_content
assert ': "slider"' not in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:10,代码来源:test_bar.py
示例14: test_custom_template_for_chart
def test_custom_template_for_chart():
data = [{
'name': '衬衫',
'value': 5
}, {
'name': '羊毛衫',
'value': 20
}, {
'name': '雪纺衫',
'value': 36
}]
configure(echarts_template_dir='.')
online()
data1 = {'衬衫': '34', '羊毛衫': 45, '雪纺衫': 40}
names, values = Bar.cast(data)
names1, values1 = Bar.cast(data1)
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", names, values, is_stack=True)
bar.add("商家B", names1, values1, is_stack=True)
bar.render(path='new_version_bar.html')
with codecs.open('new_version_bar.html', 'r', 'utf-8') as f:
actual_content = f.read()
assert "</html>" in actual_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:26,代码来源:test_custom_render.py
示例15: test_numpy_array
def test_numpy_array():
import numpy as np
title = "柱状图数据堆叠示例"
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = np.array([5, 20, 36, 10, 75, 90])
bar = Bar(title)
bar.add("商家A", attr, v1, is_stack=True)
html = bar.render_embed()
json_encoded_title = json.dumps(title)
assert json_encoded_title in html
开发者ID:shuxiang,项目名称:pyecharts,代码行数:11,代码来源:test_base.py
示例16: test_chart_properties
def test_chart_properties():
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图-数据堆叠示例", width=900, height=500)
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
eq_(len(bar.chart_id), UUID_HEX_LENGTH)
eq_(bar.width, 900)
eq_(bar.height, 500)
assert ('echarts' in bar.js_dependencies) or \
('echarts.min' in bar.js_dependencies)
开发者ID:chumingke,项目名称:pyecharts,代码行数:12,代码来源:test_chart_properties.py
示例17: get_bar
def get_bar(item_name,item_name_list,item_num_list):
subtitle = "微信公众号:大数据前沿"
bar = Bar(item_name,page_title = item_name,title_text_size=30,title_pos='center',\
subtitle = subtitle,subtitle_text_size = 25)
bar.add("", item_name_list, item_num_list,title_pos='center', xaxis_interval=0,xaxis_rotate=27,\
xaxis_label_textsize = 20,yaxis_label_textsize = 20,yaxis_name_pos='end',yaxis_pos = "%50")
bar.show_config()
grid = Grid(width=1300,height= 800)
grid.add(bar,grid_top = "13%",grid_bottom = "23%",grid_left = "15%",grid_right = "15%")
out_file_name = './analyse/'+item_name+'.html'
grid.render(out_file_name)
开发者ID:topxj,项目名称:wechat_friends,代码行数:13,代码来源:analyse.py
示例18: test_overlap_bar_line
def test_overlap_bar_line():
attr = ["A", "B", "C", "D", "E", "F"]
v1 = [10, 20, 30, 40, 50, 60]
v2 = [38, 28, 58, 48, 78, 68]
bar = Bar("Line-Bar 示例")
bar.add("bar", attr, v1)
line = Line()
line.add("line", attr, v2)
overlap = Overlap()
overlap.add(bar)
overlap.add(line)
overlap.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:13,代码来源:test_overlap.py
示例19: generic_formatter_t_est
def generic_formatter_t_est(**keywords):
attr = ["Jan", "Feb"]
v1 = [2.0, 4.9]
bar = Bar("Bar chart", "precipitation and evaporation one year")
bar.add(
"precipitation",
attr,
v1,
mark_line=["average"],
mark_point=["max", "min"],
**keywords
)
bar.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:13,代码来源:test_translator.py
示例20: test_bar_waterfall
def test_bar_waterfall():
months = ["{}月".format(i) for i in range(1, 8)]
months_v1 = [0, 100, 200, 300, 400, 220, 250]
months_v2 = [1000, 800, 600, 500, 450, 400, 300]
bar = Bar("瀑布图示例")
bar.add("", months, months_v1, label_color=['rgba(0,0,0,0)'],
is_stack=True)
bar.add("月份", months, months_v2, is_label_show=True, is_stack=True,
label_pos='inside')
bar.show_config()
bar.render()
开发者ID:chumingke,项目名称:pyecharts,代码行数:11,代码来源:test_bar.py
注:本文中的pyecharts.Bar类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论