pyecharts定制主题

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()

pyecharts定制主题_第1张图片

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()

pyecharts定制主题_第2张图片

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()

pyecharts定制主题_第3张图片

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()

pyecharts定制主题_第4张图片

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()

pyecharts定制主题_第5张图片

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()

pyecharts定制主题_第6张图片

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()

pyecharts定制主题_第7张图片

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()

pyecharts定制主题_第8张图片

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()

pyecharts定制主题_第9张图片

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()

pyecharts定制主题_第10张图片

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()

pyecharts定制主题_第11张图片

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()

pyecharts定制主题_第12张图片

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()

pyecharts定制主题_第13张图片

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()

pyecharts定制主题_第14张图片

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()

pyecharts定制主题_第15张图片

你可能感兴趣的:(pyecharts定制主题)