from pyecharts.charts import Bar #导入pyecharts 包
{Bar(柱状图)Line(折线图)Pie(饼图)Scatter(散点图) EffectScatter(涟漪散点图)Radar(雷达图)Funnel(漏斗图)Gauge(仪表盘)}
bar.add_xaxis() 增加X 轴 #bar.add_xaxis(["苹果","橘子","香蕉","西瓜"])
bar.add_yaxis('系列名',[ ],color='颜色')增加Y轴
例:bar.add_yaxis("水果店",[5,20,36,10,75],color ="red")
from pyecharts import options as opts #标题包
bar.set_global_opts(title_opts=opts.TitleOpts(title="柱状图实例",pos_left="center",pos_bottom="1%") ) 增加标题和位置
参数:pos_left
, pos_right
, pos_top
, 和 pos_bottom
center'
, 'left'
, 'right'
)或百分比
例子:bar.set_global_opts(title_opts= opts.TitleOpts(title='柱状图示列',pos_left="center",pos_bottom="1%")
增加小工具:
toolbox_opts=opts.ToolboxOpts( # 添加工具箱 is_show=True, # 是否显示工具箱 orient="horizontal", # 工具箱方向,可选 "horizontal" 或 "vertical" pos_left="center", # 工具箱位置 feature=opts.ToolBoxFeatureOpts( # 工具箱功能配置 save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(is_show=True), # 保存为图片 restore=opts.ToolBoxFeatureRestoreOpts(is_show=True), # 重置 data_view=opts.ToolBoxFeatureDataViewOpts(is_show=True), # 数据视图 magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=True), # 动态类型切换 data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=True), # 数据 ) )
from pyecharts.globals import ThemeType 背景颜色包
增加背景颜色:
bar=Bar(init_opts=op.InitOpts(theme=ThemeType.DARK))
()内更换有:
#ThemeType.LIGHT:默认亮色主题
#ThemeType.DARK:暗色主题
#ThemeType.CHALK:粉笔风格
#ThemeType.ESSOS:橙色风格
#ThemeType.INFOGRAPHIC:信息图风格