关于如何创建1 x 2 HTML表的任何想法,其中单元格{0}是matplotlib图,单元格{1}是Python 3.X的文本描述?
import matplotlib.pyplot as plt
from io import BytesIO
%matplotlib inline
def add_split_screen(fig, text, iwidth=None):
figdata = BytesIO()
fig.savefig(figdata, format='png')
figdata.seek(0)
figdata
figdata.close()
iwidth = ' width={0} '.format(iwidth) if iwidth is not None else ''
datatable = '
{0} | {1} |
display(HTML(datatable))
设置测试用例:
fig, ax = plt.subplots(1,1, figsize=(6,4))
ax.plot([1,2,3])
text = '
Special Chart:
Description of chart will go here.'
然后在Jupyter笔记本中运行该函数:
add_split_screen(fig, text, iwidth='500px')
我的输出如下:
但是,我有兴趣实际看到情节内联Jupyter笔记本 .