matplotlib怎么保存html,保存matplotlib图形上的交互式系列(html)

我有一个交互式绘图的例子(来自matplotlib),我可以从系列中选择要在绘图上显示的行。这是完美的工作,但现在我想把它导出到一个html。我可以用mpld3.save_html()成功地完成这项工作,但是在系列选择上失去了交互性。

这是密码import numpy as np

import matplotlib.pyplot as plt, mpld3

from matplotlib.widgets import CheckButtons

t = np.arange(0.0, 2.0, 0.01)

s0 = np.sin(2*np.pi*t)

s1 = np.sin(4*np.pi*t)

s2 = np.sin(6*np.pi*t)

fig, ax = plt.subplots()

l0, = ax.plot(t, s0, visible=False, lw=2)

l1, = ax.plot(t, s1, lw=2)

l2, = ax.plot(t, s2, lw=2)

plt.subplots_adjust(left=0.2)

rax = plt.axes([0.05, 0.4, 0.1, 0.15])

check = CheckButtons(rax, ('2 Hz', '4 Hz', '6 Hz'), (False, True, True))

def func(label):

if label == '2 Hz': l0.set_visible(not l0.get_visible())

elif label == '4 Hz': l1.set_visible(not l1.get_visible())

elif label == '6 Hz': l2.set_visible(not l2.get_visible())

plt.draw()

check.on_clicked(func)

mpld3.save_html(fig, 'interactive_fig.html') #save to html here

plt.show()

有没有办法保持这种互动性???在

我也尝试过用pickle保存,但还是失去了系列交互。在

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值