# 导入相关的包
import pyecharts.options as opts
from pyecharts.charts import Line

# 构造数据
x_data = ["7月" + str(i) + "日" for i in range(1,31)]
y_data = [509, 917, 2455, 2610, 2719, 3033, 3044, 3085, 2708, 2809, 2117,2000,1455,1210,719,
        733,944,2285,2208,3372,3936,3693,2962,2810,3519,2455,2610,2719,2484,2078]
y2_data = [2136,3693,2962,3810,3519,3484,3915,3823,3455,4310,4019,3433,3544,3885,4208,3372,
            3484,3915,3748,3675,4009,4433,3544,3285,4208,3372,3484,3915,3823,4265,4298]

# 实例化
line =(
    Line(opts.InitOpts(
        bg_color = "#1A1835",
    ))
    .add_xaxis(xaxis_data=x_data)
    .add_yaxis(
        y_axis=y_data,
        series_name="销售额",
        symbol="circle",
        symbol_size = 10,
        is_symbol_show=True,
        label_opts=opts.LabelOpts(is_show=False),
        itemstyle_opts=opts.ItemStyleOpts(
            color = "#6f7de3"
        )
    )
#     .render("basic_line_chart.html")
)

# 渲染效果
line.render_notebook()

渲染效果:

Python笔记:用Python绘制炫丽的折线图-LMLPHP

09-08 06:26