What would it take to put a live Matplotlib figure in a post?

I know this is out of the scope of most communities, but we are a scientific one, using Python and a lot of graphs (Matplotlib) that we share with each other over Discourse.

It would be so amazing to be able to share an interactive graph instead of a static jpg/png

Consider this example:

import matplotlib.pyplot as pltimport mpld3import numpy as npFs = 4000f = 100sample = 200x = np.arange(sample)y = np.sin(2 * np.pi * f * x / Fs)fig, ax = plt.subplots(1,1)ax.plot(x, y, marker=".")html_str = mpld3.fig_to_html(fig)Html_file= open("index.html","w")Html_file.write(html_str)Html_file.close()

You would be able to open the index.html file and it will show that (only that it will be INTERACTIVE...)

So, I feel like we're half way there, right? Perhaps just uploading the html file so it will run in some iframe?



Discuss this on our forum.