pyecharts添加背景图片
时间: 2023-09-22 15:06:58 浏览: 108
加背景.py
可以通过在初始化时指定 background_image 参数来添加背景图片,示例代码如下:
```python
from pyecharts.charts import Bar
from pyecharts import options as opts
bar = Bar()
bar.add_xaxis(['A', 'B', 'C'])
bar.add_yaxis('Series', [1, 3, 2])
bar.set_global_opts(
title_opts=opts.TitleOpts(title='Title'),
# 添加背景图片
graphic_opts=[opts.GraphicImage(
graphic_item=opts.GraphicItem(
id_='background',
right=50,
bottom=50,
z=10,
bounding='raw',
origin=[75, 75],
),
graphic_image=opts.GraphicImageOpts(
id_='background',
graphic_type='image',
graphic_image='path/to/image.jpg',
graphic_size=[150, 150],
graphic_left=-75,
graphic_top=-75,
),
)],
)
bar.render()
```
阅读全文