使用mpld3将图像转换为html

时间:2018-03-30 09:57:36

标签: python matplotlib mpld3

我正在尝试使用mpld3

导出图表的html
import matplotlib.pyplot as plt, mpld3
obj, = plt.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20)
mpld3.save_html(obj,'C:\\Users\\prabhat.mishra\\Desktop\\figure.html')

面对问题AttributeError: 'Line2D' object has no attribute 'canvas

1 个答案:

答案 0 :(得分:0)

想出solution

import matplotlib.pyplot as plt, mpld3
fig = plt.figure()
obj, = plt.plot([3,1,4,1,5])
mpld3.save_html(fig,"C:\\Users\\prabhat.mishra\\Desktop\\figure1.html")

您需要将图形对象传递给save_html