pyecharts图例字体颜色
时间: 2023-12-02 15:43:19 浏览: 313
要修改pyecharts图例的字体颜色,可以在set_global_opts()函数中使用legend_opts参数,并将其设置为opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="red")),其中color参数可以设置为任何颜色值。下面是一个例子:
```python
from pyecharts import options as opts
from pyecharts.charts import Bar, Grid
# 创建一个柱状图
bar = Bar()
# 添加数据
bar.add_xaxis(["A", "B", "C", "D", "E"])
bar.add_yaxis("Series 1", [10, 20, 30, 40, 50])
bar.add_yaxis("Series 2", [50, 40, 30, 20, 10])
# 设置全局参数,包括图例颜色和坐标轴颜色
bar.set_global_opts(
legend_opts=opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="red")),
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(color="blue")),
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(color="green"))
)
# 渲染图表
bar.render()
```
阅读全文
相关推荐


















