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

**URL:** https://meta.discourse.org/t/what-would-it-take-to-put-a-live-matplotlib-figure-in-a-post/327939
**Category:** Development
**Created:** [September 24, 2024, 3:33pm UTC](https://meta.discourse.org/t/what-would-it-take-to-put-a-live-matplotlib-figure-in-a-post/327939 "2024-09-24T15:33:59Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Alon1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alon1/32/197167_2.png) [@Alon1](https://meta.discourse.org/u/Alon1)
#### Post date: [September 24, 2024, 3:33pm UTC](https://meta.discourse.org/t/what-would-it-take-to-put-a-live-matplotlib-figure-in-a-post/327939/1 "2024-09-24T15:33:59Z")

</div>

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:

```python
import matplotlib.pyplot as plt
import mpld3
import numpy as np

Fs = 4000
f = 100
sample = 200
x = 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** …)

 ![A graph with four wavy lines, plotted on the x-axis, which corresponds to time, and y-axis, which corresponds to a variable, possibly frequency or another form of data. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/0/0/7/007bf9bf8cfe260640b56260641321697970b989.png)

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

---

_[View the full topic](https://meta.discourse.org/t/what-would-it-take-to-put-a-live-matplotlib-figure-in-a-post/327939)._
