您可以使用opts.ItemStyleOpts(color=JsCode('new echarts.graphic.LinearGradient(...)'))来设置color为线性渐变。具体的步骤如下:

  1. 导入JsCode类:from pyecharts.commons.utils import JsCode
  2. 创建线性渐变的颜色列表:gradient_color = JsCode('new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0, color: 'rgba(0, 255, 0, 1)'},{offset: 1, color: 'rgba(0, 0, 255, 1)'}])')
  3. .add_yaxis()中设置itemstyle_optscolor为线性渐变:.add_yaxis('购物量', df2.values.tolist(), itemstyle_opts=opts.ItemStyleOpts(color=gradient_color))

这样就可以将颜色设置为线性渐变了。您可以根据需要调整渐变的起始颜色和结束颜色,以及渐变的方向和位置。

Pyecharts线性渐变:在.add_yaxis()中设置颜色渐变

原文地址: https://www.cveoy.top/t/topic/fnOd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录