本文整理匯總了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')