python画图保存网页_有没有一种方法可以将多个绘图保存到html中

我希望以下来自here的示例能够满足您的需求:import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import mpld3

from mpld3 import plugins

# Define some CSS to control our custom labels

css = """

table

{

border-collapse: collapse;

}

th

{

color: #ffffff;

background-color: #000000;

}

td

{

background-color: #cccccc;

}

table, th, td

{

font-family:Arial, Helvetica, sans-serif;

border: 1px solid black;

text-align: right;

}

"""

fig, ax = plt.subplots()

ax.grid(True, alpha=0.3)

N = 50

df = pd.DataFrame(index=range(N))

df['x'] = np.random.randn(N)

df['y'] = np.random.randn(N)

df['z'] = np.random.randn(N)

labels = []

for i in range(N):

label = df.ix[[i], :].T

label.columns = ['Row {0}'.format(i)]

# .to_html() is unicode; so make leading 'u' go away with str()

labels.append(str(label.to_html()))

points = ax.plot(df.x, df.y, 'o', color='b',

mec='k', ms=15, mew=1, alpha=.6)

ax.set_xlabel('x')

ax.set_ylabel('y')

ax.set_title('HTML tooltips', size=20)

tooltip = plugins.PointHTMLTooltip(points[0], labels,

voffset=10, hoffset=10, css=css)

plugins.connect(fig, tooltip)

mpld3.show()Output:

QZcvD.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值