pyecharts更新v1.0啦,简直水行数的利器
一、 v0.5.x版本
支持2.7,3.4+
def lineDraw(info):
date, win, use = info[0], info[1], info[2]
line = Line("胜率与使用率", background_color="#FFF") # 默认背景颜色是黑的,需要重新配置一下,#FFF就是纯白
line.add("胜率", date, win, label_color=["#FF0033", "#4169E1"], yaxis_formatter="%", is_smooth=True,
is_fill=True, area_opacity=0.3, mark_line=["average"], mark_point=["max", "min"],
mark_point_textcolor="#000")
line.add("使用率", date, use, yaxis_formatter="%", is_smooth=True, is_fill=True,
area_opacity=0.5, mark_line=["average"], mark_point=["max", "min"])
line.render()
二、 v1.0版本
支持3.6+,万物皆可opts
def lineDraw(info):
date, win, use = info[0], info[1], info[2]
line = (
Line(init_opts=opts.InitOpts(bg_color="white"))
.add_xaxis(date) # 增加x轴
.add_yaxis("胜率", win, is_smooth=True,
areastyle_opts=opts.AreaStyleOpts(opacity=0.3), color="#4169E1") # 增加y轴,设置曲线流畅,透明度,曲线颜色
.add_yaxis("使用率", use, is_smooth=True,
areastyle_opts=opts.AreaStyleOpts(opacity=0.5), color="#FF0033") # 增加y轴
.set_global_opts(
title_opts=opts.TitleOpts(title="胜率与使用率", subtitle="皮卡"),
xaxis_opts=opts.AxisOpts(
axistick_opts=opts.AxisTickOpts(is_align_with_label=True),
is_scale=False,
boundary_gap=False
), # 图像贴近y轴
yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True)) # 增加y轴分割线
) # 全局配置项
.set_series_opts(
markpoint_opts=opts.MarkPointOpts(
data=[opts.MarkPointItem(type_="max"), opts.MarkPointItem(type_="min")],
symbol_size=[34, 30],
label_opts=opts.LabelOpts(position="inside", color="#fff", font_size=8)
),
label_opts=opts.LabelOpts(is_show=False),
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")])
) # 系列配置项
)
make_snapshot(snapshot, line.render(), outputfile)