gpt4 book ai didi

html - 如何使用 mpld3 将 xkcd 图导入 html

转载 作者:可可西里 更新时间:2023-11-01 14:47:35 25 4
gpt4 key购买 nike

我正在尝试将 matplotlib 导入到带有 xkcd 主题的 html 中。我的代码如下(没有数据,只是一张图)

fig = plt.figure(facecolor = '#eee8d5')
#plt.matplotlib.rcdefaults()
with plt.xkcd():

ax = fig.add_subplot(111)

ax.set_axis_bgcolor('#eee8d5') #set_color('#fdf6e3')

ax.title.set_color('#d33682') # Magenta

ax.tick_params(axis='x', colors='#657b83')
ax.tick_params(axis='y', colors='#657b83')


ax.spines['bottom'].set_color('#657b83')
ax.spines['left'].set_color('#657b83')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')

ax.set_title('Title', fontsize = 18);
html = mpld3.fig_to_html(fig)
Html_file= open("CumPrctWordFrq.html","w")
Html_file.write(html)
Html_file.close()

到目前为止一切顺利——一切都在 python 笔记本中正确呈现。但是,当我将 html 粘贴到网站 (squarespace) 时,无花果丢失了所有 xkcd 属性。最后我想让这个互动。这个想法最终是产生一个 xkcd -> solarized -> interactive plot。

最佳答案

mpld3 尚不支持 plt.xkcd() 模式。如果这是你想要的,你应该在 the mpld3 issue tracker 中创建一个问题,然后看看是否有人受到启发来从事这项工作。

关于html - 如何使用 mpld3 将 xkcd 图导入 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27082646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com