Created
May 2, 2022 12:16
-
-
Save SpiralOutDotEu/344dd29b59b94aeba91aa574b092e535 to your computer and use it in GitHub Desktop.
Python Script Inside HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
<script defer src="https://pyscript.net/alpha/pyscript.min.js"></script> | |
<py-env> | |
- numpy | |
- matplotlib | |
</py-env> | |
</head> | |
<body> | |
<h1>Let's plot random numbers</h1> | |
<h3>....wait for plot to appear</h3> | |
<div id="plot"></div> | |
<py-script output="plot"> | |
import matplotlib.pyplot as plt | |
import numpy as np | |
x = np.random.randn(1000) | |
y = np.random.randn(1000) | |
fig, ax = plt.subplots() | |
ax.scatter(x, y) | |
fig | |
</py-script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment