I've searched a lot on this topic but I'm not a web developer so I know I'm missing some concepts.
When I run matplotlib locally and specify the 'webagg' backend, running plt.show() starts a lightweight webserver and opens the plot in my browser with full interactive functionality.
import matplotlib as mpl
mpl.use('webagg')
from matplotlib import pyplot as plt
import numpy as np
f,ax = plt.subplots(1)
ydata = np.random.randint(0,100,100)
xdata = np.linspace(1,100,100)
ax.plot(xdata,ydata,picker=5)
ax.set_title('Click the line to change the color')
def onpick(event):
event.artist.set_color('red')
f.canvas.draw_idle()
f.canvas.mpl_connect('pick_event', onpick)
plt.show()
My question is: Is it possible to use the webagg backend with my django website to serve neat interactive matplotlib figures to users? In other words, can I use the above code somewhere in my django site such that the plot will embed in a web page?
(I know about tools like mpld3, which are very cool, but don't fully recreate the widget/picker functionality in matplotlib).