Last active
May 4, 2022 19:54
-
-
Save KenoLeon/ce8df6bb7d1259fa494d1b0deb4deeed to your computer and use it in GitHub Desktop.
Pyplot in the browser with Pyscript
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Pyplot in the Browser</title> | |
| <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
| <script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
| <py-env> | |
| - numpy | |
| - matplotlib | |
| </py-env> | |
| </head> | |
| <body> | |
| <div id="plot"></div> | |
| <py-script output="plot"> | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| x = np.random.rand(100) | |
| y = np.random.rand(100) | |
| 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