Created
May 8, 2022 05:50
-
-
Save chinmay29hub/f3fb4fac0a7a6b24f9de6dad32ebc8e7 to your computer and use it in GitHub Desktop.
A simple pyscript for dealing with libraries
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
<!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>Document</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> | |
<style> | |
#plot { | |
border-style: dashed; | |
border-width: 5px; | |
border-color: #ff0000; | |
width: 32%; | |
} | |
</style> | |
</head> | |
<body> | |
<h1 style="font-size: 70px; font-weight: bolder; color: rgb(52, 83, 219);">Let's plot random numbers</h1> | |
<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) | |
pyscript.write('plot', fig) | |
</py-script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment