pyecharts传入Numpy数据绘图失败
编辑日期: 2024-11-28 文章阅读: 次
@author jackzhenguo
@desc
@tag
@version
@date 2020/03/05
pyecharts传入Numpy数据绘图失败
echarts使用广泛,echarts+python结合后的包:pyecharts,同样可很好用,但是传入Numpy的数据,像下面这样绘图会失败:
from pyecharts.charts import Bar
import pyecharts.options as opts
import numpy as np
c = (
Bar()
.add_xaxis([1, 2, 3, 4, 5])
.add_yaxis("商家A", np.array([0.1, 0.2, 0.3, 0.4, 0.5]))
)
c.render()
由此可见pyecharts对Numpy数据绘图不支持,传入原生Python的list:
from pyecharts.charts import Bar
import pyecharts.options as opts
import numpy as np
c = (
Bar()
.add_xaxis([1, 2, 3, 4, 5])
.add_yaxis("商家A", np.array([0.1, 0.2, 0.3, 0.4, 0.5]).tolist())
)
c.render()