主题设置
所有主题
from pyecharts.globals import ThemeType
# 虚假数据
x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data_1 = [123, 153, 89, 107, 98, 23]
y_data_2 = [231, 321, 135, 341, 245, 167]
# 所有内置主题
theme_list = ['chalk',
'dark',
'essos',
'infographic',
'light',
'macarons',
'purple-passion',
'roma',
'romantic',
'shine',
'vintage',
'walden',
'westeros',
'white',
'wonderland']
page = Page()
for t in theme_list:
bar = (
Bar(init_opts=opts.InitOpts(
# 设置主题
theme=t))
.add_xaxis(x_data)
.add_yaxis('', y_data_1)
.add_yaxis('', y_data_2)
.set_global_opts(title_opts=opts.TitleOpts("Theme-{}".format(t)))
)
page.add(bar)
page.render_notebook()