pyecharts内置提供了10+种不同的风格,另外也提供了便捷的定制主题的方法
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType
x=['衬衫','羊毛衫','雪纺衫','裤子','高跟鞋','袜子']
y1=[3,4,6,8,9,0]
y2=[15,6,45,20,35]
y3=[56,47,34,24,23,66]
y4=[34,56,23,44,23,11]
默认主题
bar=pyec.Bar()
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.render_notebook()
LIGHT
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='LIGHT'))
bar.render_notebook()
DARK
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='DARK'))
bar.render_notebook()
CHALK
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.CHALK))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='CHALK'))
bar.render_notebook()
ESSOS
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.ESSOS))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='ESSOS'))
bar.render_notebook()
INFOGRAPHIC
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.INFOGRAPHIC))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='INFOGRAPHIC'))
bar.render_notebook()
MACARONS
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='MACARONS'))
bar.render_notebook()
PURPLE_PASSION
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.PURPLE_PASSION))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='PURPLE_PASSION'))
bar.render_notebook()
ROMA
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.ROMA))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='ROMA'))
bar.render_notebook()
ROMANTIC
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.ROMANTIC))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='ROMANTIC'))
bar.render_notebook()
SHINE
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.SHINE))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='SHINE'))
bar.render_notebook()
VINTAGE
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='VINTAGE'))
bar.render_notebook()
WALDEN
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.WALDEN))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='WALDEN'))
bar.render_notebook()
WESTEROS
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.WESTEROS))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='WESTEROS'))
bar.render_notebook()
WONDERLAND
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.WONDERLAND))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.set_global_opts(title_opts=opts.TitleOpts(title='WONDERLAND'))
bar.render_notebook()