How to import xkcd fig into html using mpld3

I am trying to import matplotlib into html with an xkcd theme. My code looks like this (no data, just fig)

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()

      

So far so good - everything displays correctly in python notebook. However, when I paste the html into the website (square), pic loses all xkcd properties. Eventually I would like to make it interactive. The idea is to create an interactive plot xkcd -> solarized ->.

+3


source to share


1 answer


mpld3

does not support the mode yet plt.xkcd()

. If that's what you want, you should create a problem mpld3

tracker
and see if anyone inspires anyone to work for it.



+1


source







All Articles