本文整理汇总了Python中pyecharts.Bar方法的典型用法代码示例。如果您正苦于以下问题:Python pyecharts.Bar方法的具体用法?Python pyecharts.Bar怎么用?Python pyecharts.Bar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyecharts
的用法示例。
在下文中一共展示了pyecharts.Bar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_with_chart
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def show_with_chart(top_10):
"""
把最低的十个城市和温度生成饼状图
:param top_10:
:return:
"""
# 1.获取城市列表
citys = list(map(lambda item: item['city'], top_10))
# 2.最低温度列表
temp_lows = list(map(lambda item: item['temp_low'], top_10))
# 3.生成饼状图并写入到html文件中
bar = Bar("最低气温排行榜")
bar.add("最低温度", citys, temp_lows)
# 渲染
bar.render('temperature.html')
示例2: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
# all_poet = [i[0] for i in data[:30]]
# all_num = [i[1] for i in data[:30]]
# br = pyecharts.Bar(title=file.rstrip('.txt')+'最高频的多字意象:', title_top=0, width=1200, height=700,)
# br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
# br.use_theme('dark')
# br.render(path=file.rstrip('.txt')+'最高频的多字意象:_条形图'+'.html')
all_poet = [i[0] for i in data[:500]]
all_num = [i[1] for i in data[:500]]
wordcloud = WordCloud(title='\n'+file.rstrip('.txt')+'多字意象分析',title_pos='center', width=1300, height=620, )
shape = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
wordcloud.add('', all_poet, all_num,
shape= random.choice(shape),
word_gap=20,
word_size_range=[10, 120],
rotate_step=45)
wordcloud.render(path=file.rstrip('.txt')+'最高频的多字意象_词云'+'.html')
示例3: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
# all_poet = [i[0] for i in data[:30]]
# all_num = [i[1] for i in data[:30]]
# br = pyecharts.Bar(title=file.rstrip('.txt')+'最爱用的单字意象:', title_top=0, width=1200, height=700,)
# br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
# br.use_theme('dark')
# br.render(path=file.rstrip('.txt')+'最爱用的单字意象:_条形图'+'.html')
all_poet = [i[0] for i in data[:500]]
all_num = [i[1] for i in data[:500]]
wordcloud = WordCloud(width=1300, height=620, )
shape = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
wordcloud.add('', all_poet, all_num,
shape= random.choice(shape),
word_gap=20,
word_size_range=[10, 120],
rotate_step=45)
wordcloud.render(path=file.rstrip('.txt')+'最爱用的单字意象_词云'+'.html')
示例4: bar_chart
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def bar_chart():
d = db.session.query(func.count(extract('Day', Purchase.purchase_addtime)),
extract('Day', Purchase.purchase_addtime)).group_by(
extract('Day', Purchase.purchase_addtime)
).all()
attr = ["{}号".format(j) for _,j in d]
v1 = [i for i,_ in d]
bar = Bar("日采购量")
bar.add(
"",
attr,
v1,
is_datazoom_show=True,
datazoom_type="both",
datazoom_range=[10, 25],
)
return bar
# 销售表格
# 销售量
示例5: create_simple_bar
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def create_simple_bar():
bar = Bar("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90])
bar.renderer = 'svg'
return bar
示例6: get_echarts_instance
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def get_echarts_instance(self, *args, **kwargs):
device_data = models.Device.objects.values('device_type').annotate(count=Count('device_type'))
device_types, counters = fetch(device_data, 'device_type', 'count')
pie = Pie("设备分类", page_title='设备分类', width='100%')
pie.add("设备分类", device_types, counters, is_label_show=True)
battery_lifes = models.Device.objects.values('name', 'battery_life')
names, lifes = fetch(battery_lifes, 'name', 'battery_life')
bar = Bar('设备电量', page_title='设备电量', width='100%')
bar.add("设备电量", names, lifes)
page = Page.from_charts(pie, bar)
return page
示例7: get_echarts_instance
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def get_echarts_instance(self, *args, **kwargs):
bar = Bar("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90])
return bar
示例8: plot_chart
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def plot_chart(counter, chart_type='Bar'):
items = [item[0] for item in counter]
values = [item[1] for item in counter]
if chart_type == 'Bar':
chart = Bar('微博动态词频统计')
chart.add('词频', items, values, is_more_utils=True)
else:
chart = Pie('微博动态词频统计')
chart.add('词频', items, values, is_label_show=True, is_more_utils=True)
chart.render('weibo_wordfrq.html')
#画出微博发布时间的统计图
示例9: plot_create_time
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def plot_create_time(time_lists):
recent_time = re.compile(r'\d{2}月\d{2}日',re.S)
long_time = re.compile(r'(\d{4}-\d{2}-\d{2})',re.S)
tmp_lists = []#保存**月**日格式的数据
tmp_nums = []#统计**月**日发帖数量
long_lists = []#保存20**-**-**格式的数据
long_nums = []#统计20**-**-**发帖数量
for t in time_lists:
res = re.findall(recent_time, t)
if(res):#res[0]为**月**日格式的数据
if(not tmp_lists or res[0]!= tmp_lists[-1]):#列表为空或者不与前一个日期重复
tmp_lists.append(res[0])
tmp_nums.append(1)
else:#与前一个日期重复,计数加一
tmp_nums[-1]+=1
else:#res[0]20**-**-**格式的数据
res = re.findall(long_time,t)
if(not long_lists or res[0]!=long_lists[-1]):
long_lists.append(res[0])
long_nums.append(1)
else:
long_nums[-1]+=1
#将时间按照从远到进的顺序排列
tmp_lists.reverse()
tmp_nums.reverse()
long_lists.reverse()
long_nums.reverse()
time_list = long_lists + tmp_lists
time_nums = long_nums + tmp_nums
chart = Bar('用户微博动态发布时间')
chart.add('动态数', time_list, time_nums, is_more_utils=True,datazoom_range=[10,40],is_datazoom_show=True)
chart.render("weibo_dynamic.html")
#可以指定需要分析的用户的uid(必须先存在conf.yaml里面,并且运行了一次sina_spider程序)
示例10: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
all_poet = [i[0] for i in data[:30]]
all_num = [i[1] for i in data[:30]]
br = pyecharts.Bar(title=file.rstrip('.txt')+'最受欢迎的词牌', title_top=0, width=1200, height=700,)
br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
br.use_theme('dark')
br.render(path=file.rstrip('.txt')+'最受欢迎的词牌_条形图'+'.html')
all_poet = [i[0] for i in data[:1000]]
all_num = [i[1] for i in data[:1000]]
wordcloud = WordCloud(width=1300, height=620)
wordcloud.add("", all_poet, all_num, word_size_range=[5, 50])
wordcloud.render(path=file.rstrip('.txt')+'最受欢迎的词牌_词云'+'.html')
示例11: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
pyecharts.configure(
jshost=None,
echarts_template_dir=None,
force_js_embed=None,
output_image=None,
global_theme='vintage'
)
all_poet = [i[0] for i in data[:30]]
all_num = [i[1] for i in data[:30]]
br = pyecharts.Bar(title=file.rstrip('.txt')+'诗人最爱用的动词', title_top=0, width=1200, height=700,)
br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
br.use_theme("vintage")
br.render(path=file.rstrip('.txt')+'诗人最爱用的动词_条形图'+'.html')
all_poet = [i[0] for i in data[:600]]
all_num = [i[1] for i in data[:600]]
wordcloud = WordCloud(title='\n'+file.rstrip('.txt')+'诗人最爱用的动词',title_pos='center', width=1500, height=800, )
shape = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
wordcloud.add('', all_poet, all_num,
shape= random.choice(shape),
word_gap=20,
word_size_range=[10, 120],
rotate_step=80)
wordcloud.render(path=file.rstrip('.txt')+'诗人最爱用的动词_词云'+'.html')
示例12: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
pyecharts.configure(
jshost=None,
echarts_template_dir=None,
force_js_embed=None,
output_image=None,
global_theme='infographic'
)
all_poet = [i[0] for i in data[:30]]
all_num = [i[1] for i in data[:30]]
br = pyecharts.Bar(title=file.rstrip('.txt')+'最常见的地名', title_top=0, width=1200, height=700,)
br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
br.use_theme('infographic')
br.render(path=file.rstrip('.txt')+'最常见的地名_条形图'+'.html')
all_poet = [i[0] for i in data[:700]]
all_num = [i[1] for i in data[:700]]
wordcloud = WordCloud(title=file.rstrip('.txt')+'最常见的地名'+'\n\n', title_pos='center', width=1500, height=800, )
shape = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
wordcloud.add('', all_poet, all_num,
shape= random.choice(shape),
word_gap=20,
word_size_range=[10, 120],
rotate_step=70)
wordcloud.render(path=file.rstrip('.txt')+'最常见的地名_词云'+'.html')
示例13: pic
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def pic(data, file):
pyecharts.configure(
jshost=None,
echarts_template_dir=None,
force_js_embed=None,
output_image=None,
global_theme='shine'
)
all_poet = [i[0] for i in data[:30]]
all_num = [i[1] for i in data[:30]]
br = pyecharts.Bar(title=file.rstrip('.txt')+'诗人最爱用的形容词', title_top=0, width=1200, height=700,)
br.add('', all_poet, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
br.use_theme('shine')
br.render(path=file.rstrip('.txt')+'诗人最爱用的形容词_条形图'+'.html')
all_poet = [i[0] for i in data[:600]]
all_num = [i[1] for i in data[:600]]
wordcloud = WordCloud(title='\n'+file.rstrip('.txt')+'诗人最爱用的形容词',title_pos='center', width=1500, height=800, )
shape = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
wordcloud.add('', all_poet, all_num,
shape= random.choice(shape),
word_gap=20,
word_size_range=[10, 120],
rotate_step=70)
wordcloud.render(path=file.rstrip('.txt')+'诗人最爱用的形容词_词云'+'.html')
示例14: show
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def show(data, file):
es = pyecharts.Bar(title=file.rstrip('.txt')+'字频', title_top=100, width=1300, height=700,)
flag = 1
for title, num in data:
if num < 10000:
pass
else:
es.add(title, [flag], [num],xaxis_interval=0, yaxis_interval=0)
flag += 1
es.render(path=file.rstrip('.txt')+'_字频'+'.html')
示例15: show
# 需要导入模块: import pyecharts [as 别名]
# 或者: from pyecharts import Bar [as 别名]
def show(data, file):
'''展示图表'''
all_ci = [i[0] for i in data]
all_num = [i[1] for i in data]
rank_bar = pyecharts.Bar('\n{}词频榜'.format(file.rstrip('.txt')), width=1400, height=750, title_pos='center', title_top=3) # 初始化图表
# all_names是所有电影名,作为X轴, all_lovers是关注者的数量,作为Y轴。二者数据一一对应。 is_label_show=True,
# is_convert=True设置x、y轴对调,。is_label_show=True 显示y轴值。 label_pos='right' Y轴值显示在右边
rank_bar.add('', all_ci, all_num, label_pos='center',is_convert=True, xaxis_interval=0, yaxis_interval=0, is_yaxis_inverse=True)
rank_bar.render(path=file.rstrip('.txt')+'_词频'+'.html')