Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.05 KB

167.md

File metadata and controls

48 lines (37 loc) · 1.05 KB
@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])
    # 传入Numpy数据绘图失败!
    .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])
    # 传入Python原生list
    .add_yaxis("商家A", np.array([0.1, 0.2, 0.3, 0.4, 0.5]).tolist())
)

c.render()

[上一个例子](166.md) [下一个例子](168.md)